aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorJesper Juhl <jj@chaosbits.net>2012-08-07 07:56:26 -0400
committerDavid S. Miller <davem@davemloft.net>2012-08-08 19:04:47 -0400
commit47dffc7547ed3b105dabd570ed864347687beac2 (patch)
tree92cedaf0ddd3ea1e6d7c18dae57f3f268852cf42 /drivers/net
parent155e4e12b9f49c2dc817bb4c44e9416c46833c3d (diff)
cdc-phonet: Don't leak in usbpn_open
We allocate memory for 'req' with usb_alloc_urb() and then test 'if (!req || rx_submit(pnd, req, GFP_KERNEL | __GFP_COLD))'. If we enter that branch due to '!req' then there is no problem. But if we enter the branch due to 'req' being != 0 and the 'rx_submit()' call being false, then we'll leak the memory we allocated. Deal with the leak by always calling 'usb_free_urb(req)' when entering the branch. If 'req' happens to be 0 then the call is harmless, if it is not 0 then we free the memory we allocated but don't need. Signed-off-by: Jesper Juhl <jj@chaosbits.net> Acked-by: RĂ©mi Denis-Courmont <remi@remlab.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/usb/cdc-phonet.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/net/usb/cdc-phonet.c b/drivers/net/usb/cdc-phonet.c
index 64610048ce87..7d78669000d7 100644
--- a/drivers/net/usb/cdc-phonet.c
+++ b/drivers/net/usb/cdc-phonet.c
@@ -232,6 +232,7 @@ static int usbpn_open(struct net_device *dev)
232 struct urb *req = usb_alloc_urb(0, GFP_KERNEL); 232 struct urb *req = usb_alloc_urb(0, GFP_KERNEL);
233 233
234 if (!req || rx_submit(pnd, req, GFP_KERNEL | __GFP_COLD)) { 234 if (!req || rx_submit(pnd, req, GFP_KERNEL | __GFP_COLD)) {
235 usb_free_urb(req);
235 usbpn_close(dev); 236 usbpn_close(dev);
236 return -ENOMEM; 237 return -ENOMEM;
237 } 238 }