mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
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 <[email protected]> Acked-by: Stephane Grosjean <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
This commit is contained in:
parent
8a9a0ea603
commit
a49bcabedc
1 changed files with 2 additions and 0 deletions
|
|
@ -875,6 +875,7 @@ static int pcan_usb_pro_init(struct peak_usb_device *dev)
|
|||
PCAN_USBPRO_INFO_FW,
|
||||
&fi, sizeof(fi));
|
||||
if (err) {
|
||||
kfree(usb_if);
|
||||
dev_err(dev->netdev->dev.parent,
|
||||
"unable to read %s firmware info (err %d)\n",
|
||||
pcan_usb_pro.name, err);
|
||||
|
|
@ -885,6 +886,7 @@ static int pcan_usb_pro_init(struct peak_usb_device *dev)
|
|||
PCAN_USBPRO_INFO_BL,
|
||||
&bi, sizeof(bi));
|
||||
if (err) {
|
||||
kfree(usb_if);
|
||||
dev_err(dev->netdev->dev.parent,
|
||||
"unable to read %s bootloader info (err %d)\n",
|
||||
pcan_usb_pro.name, err);
|
||||
|
|
|
|||
Loading…
Reference in a new issue