Re: [PATCH] cdc-phonet: Don't leak in usbpn_open
From: Rémi Denis-Courmont
Date: Wed Aug 08 2012 - 03:12:05 EST
Le mercredi 8 août 2012 00:56:26 Jesper Juhl, vous avez écrit :
> 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@xxxxxxxxxxxxx>
Acked-by: Rémi Denis-Courmont <remi@xxxxxxxxxx>
> ---
> drivers/net/usb/cdc-phonet.c | 1 +
> 1 file changed, 1 insertion(+)
>
> Only compile tested due to lack of hardware.
Hardware won't help you much with testing the error case anyway.
--
Rémi Denis-Courmont, looking for a job
http://www.remlab.net/
http://fi.linkedin.com/in/remidenis
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/