diff options
author | Dan Carpenter <error27@gmail.com> | 2010-04-26 19:20:12 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-04-27 17:49:07 -0400 |
commit | d87ff58fda926fe5cb01214cccf1c72422ac776d (patch) | |
tree | 896ae06e804c24fd02b254896a884d2f5d30fe4a | |
parent | 2a9151572224ad5fe808058097be94106470a6dc (diff) |
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>
-rw-r--r-- | drivers/net/usb/ipheth.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/net/usb/ipheth.c b/drivers/net/usb/ipheth.c index fd1033130a81..418825d26f90 100644 --- a/drivers/net/usb/ipheth.c +++ b/drivers/net/usb/ipheth.c | |||
@@ -122,25 +122,25 @@ static int ipheth_alloc_urbs(struct ipheth_device *iphone) | |||
122 | 122 | ||
123 | tx_urb = usb_alloc_urb(0, GFP_KERNEL); | 123 | tx_urb = usb_alloc_urb(0, GFP_KERNEL); |
124 | if (tx_urb == NULL) | 124 | if (tx_urb == NULL) |
125 | goto error; | 125 | goto error_nomem; |
126 | 126 | ||
127 | rx_urb = usb_alloc_urb(0, GFP_KERNEL); | 127 | rx_urb = usb_alloc_urb(0, GFP_KERNEL); |
128 | if (rx_urb == NULL) | 128 | if (rx_urb == NULL) |
129 | goto error; | 129 | goto free_tx_urb; |
130 | 130 | ||
131 | tx_buf = usb_buffer_alloc(iphone->udev, | 131 | tx_buf = usb_buffer_alloc(iphone->udev, |
132 | IPHETH_BUF_SIZE, | 132 | IPHETH_BUF_SIZE, |
133 | GFP_KERNEL, | 133 | GFP_KERNEL, |
134 | &tx_urb->transfer_dma); | 134 | &tx_urb->transfer_dma); |
135 | if (tx_buf == NULL) | 135 | if (tx_buf == NULL) |
136 | goto error; | 136 | goto free_rx_urb; |
137 | 137 | ||
138 | rx_buf = usb_buffer_alloc(iphone->udev, | 138 | rx_buf = usb_buffer_alloc(iphone->udev, |
139 | IPHETH_BUF_SIZE, | 139 | IPHETH_BUF_SIZE, |
140 | GFP_KERNEL, | 140 | GFP_KERNEL, |
141 | &rx_urb->transfer_dma); | 141 | &rx_urb->transfer_dma); |
142 | if (rx_buf == NULL) | 142 | if (rx_buf == NULL) |
143 | goto error; | 143 | goto free_tx_buf; |
144 | 144 | ||
145 | 145 | ||
146 | iphone->tx_urb = tx_urb; | 146 | iphone->tx_urb = tx_urb; |
@@ -149,13 +149,14 @@ static int ipheth_alloc_urbs(struct ipheth_device *iphone) | |||
149 | iphone->rx_buf = rx_buf; | 149 | iphone->rx_buf = rx_buf; |
150 | return 0; | 150 | return 0; |
151 | 151 | ||
152 | error: | 152 | free_tx_buf: |
153 | usb_buffer_free(iphone->udev, IPHETH_BUF_SIZE, rx_buf, | ||
154 | rx_urb->transfer_dma); | ||
155 | usb_buffer_free(iphone->udev, IPHETH_BUF_SIZE, tx_buf, | 153 | usb_buffer_free(iphone->udev, IPHETH_BUF_SIZE, tx_buf, |
156 | tx_urb->transfer_dma); | 154 | tx_urb->transfer_dma); |
155 | free_rx_urb: | ||
157 | usb_free_urb(rx_urb); | 156 | usb_free_urb(rx_urb); |
157 | free_tx_urb: | ||
158 | usb_free_urb(tx_urb); | 158 | usb_free_urb(tx_urb); |
159 | error_nomem: | ||
159 | return -ENOMEM; | 160 | return -ENOMEM; |
160 | } | 161 | } |
161 | 162 | ||