• Jesper Juhl's avatar
    cdc-phonet: Don't leak in usbpn_open · 47dffc75
    Jesper Juhl authored
    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: default avatarJesper Juhl <jj@chaosbits.net>
    Acked-by: default avatarRémi Denis-Courmont <remi@remlab.net>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    47dffc75
cdc-phonet.c 10.7 KB