Skip to content

Commit d87ff58

Browse files
error27davem330
authored andcommitted
ipheth: potential null dereferences on error path
The calls to usb_free_buffer() dereference rx_urb and tx_urb in the parameter list but those could be NULL. Signed-off-by: Dan Carpenter <error27@gmail.com> Acked-by: L. Alberto Giménez <agimenez@sysvalve.es> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 2a91515 commit d87ff58

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

‎drivers/net/usb/ipheth.c‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,25 +122,25 @@ static int ipheth_alloc_urbs(struct ipheth_device *iphone)
122122

123123
tx_urb = usb_alloc_urb(0, GFP_KERNEL);
124124
if (tx_urb == NULL)
125-
goto error;
125+
goto error_nomem;
126126

127127
rx_urb = usb_alloc_urb(0, GFP_KERNEL);
128128
if (rx_urb == NULL)
129-
goto error;
129+
goto free_tx_urb;
130130

131131
tx_buf = usb_buffer_alloc(iphone->udev,
132132
IPHETH_BUF_SIZE,
133133
GFP_KERNEL,
134134
&tx_urb->transfer_dma);
135135
if (tx_buf == NULL)
136-
goto error;
136+
goto free_rx_urb;
137137

138138
rx_buf = usb_buffer_alloc(iphone->udev,
139139
IPHETH_BUF_SIZE,
140140
GFP_KERNEL,
141141
&rx_urb->transfer_dma);
142142
if (rx_buf == NULL)
143-
goto error;
143+
goto free_tx_buf;
144144

145145

146146
iphone->tx_urb = tx_urb;
@@ -149,13 +149,14 @@ static int ipheth_alloc_urbs(struct ipheth_device *iphone)
149149
iphone->rx_buf = rx_buf;
150150
return 0;
151151

152-
error:
153-
usb_buffer_free(iphone->udev, IPHETH_BUF_SIZE, rx_buf,
154-
rx_urb->transfer_dma);
152+
free_tx_buf:
155153
usb_buffer_free(iphone->udev, IPHETH_BUF_SIZE, tx_buf,
156154
tx_urb->transfer_dma);
155+
free_rx_urb:
157156
usb_free_urb(rx_urb);
157+
free_tx_urb:
158158
usb_free_urb(tx_urb);
159+
error_nomem:
159160
return -ENOMEM;
160161
}
161162

0 commit comments

Comments
 (0)