mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-15 05:11:32 +00: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 <jj@chaosbits.net> Acked-by: Stephane Grosjean <s.grosjean@peak-system.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
parent
8a9a0ea603
commit
a49bcabedc
@ -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 New Issue
Block a user