can: usb: PCAN-USB Pro: fix mem leaks in pcan_usb_pro_init() on error paths
authorJesper Juhl <jj@chaosbits.net>
Wed, 11 Apr 2012 21:23:41 +0000 (23:23 +0200)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Mon, 16 Apr 2012 19:34:50 +0000 (21:34 +0200)
commita49bcabedc18319f673319d5e71b5751e3978179
treebeefbfa8bee452e5876bff2fef0b49b397c1b332
parent8a9a0ea6032186e3030419262678d652b88bf6a8
can: usb: PCAN-USB Pro: fix mem leaks in pcan_usb_pro_init() on error paths

If either call to pcan_usb_pro_send_req() in
drivers/net/can/usb/peak_usb/pcan_usb_pro.c::pcan_usb_pro_init()
fails, we'll leak the memory we allocated to 'usb_if' with kzalloc()
when the 'usb_if' variable goes out of scope without having been
assigned to anything as we 'return err;'.
Fix this by adding appropriate kfree(usb_if) calls to the error paths.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Acked-by: Stephane Grosjean <s.grosjean@peak-system.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/usb/peak_usb/pcan_usb_pro.c