mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-16 16:54:20 +08:00
can: peak_usb: fix cleanup sequence order in case of error during init
This patch sets the correct reverse sequence order to the instructions set to run, when any failure occurs during the initialization steps. It also adds the missing unregistration call of the can device if the failure appears after having been registered. Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com> Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
parent
dc50ddcd4c
commit
af35d0f1cc
@ -735,7 +735,7 @@ static int peak_usb_create_dev(struct peak_usb_adapter *peak_usb_adapter,
|
||||
dev->cmd_buf = kmalloc(PCAN_USB_MAX_CMD_LEN, GFP_KERNEL);
|
||||
if (!dev->cmd_buf) {
|
||||
err = -ENOMEM;
|
||||
goto lbl_set_intf_data;
|
||||
goto lbl_free_candev;
|
||||
}
|
||||
|
||||
dev->udev = usb_dev;
|
||||
@ -775,7 +775,7 @@ static int peak_usb_create_dev(struct peak_usb_adapter *peak_usb_adapter,
|
||||
err = register_candev(netdev);
|
||||
if (err) {
|
||||
dev_err(&intf->dev, "couldn't register CAN device: %d\n", err);
|
||||
goto lbl_free_cmd_buf;
|
||||
goto lbl_restore_intf_data;
|
||||
}
|
||||
|
||||
if (dev->prev_siblings)
|
||||
@ -788,14 +788,14 @@ static int peak_usb_create_dev(struct peak_usb_adapter *peak_usb_adapter,
|
||||
if (dev->adapter->dev_init) {
|
||||
err = dev->adapter->dev_init(dev);
|
||||
if (err)
|
||||
goto lbl_free_cmd_buf;
|
||||
goto lbl_unregister_candev;
|
||||
}
|
||||
|
||||
/* set bus off */
|
||||
if (dev->adapter->dev_set_bus) {
|
||||
err = dev->adapter->dev_set_bus(dev, 0);
|
||||
if (err)
|
||||
goto lbl_free_cmd_buf;
|
||||
goto lbl_unregister_candev;
|
||||
}
|
||||
|
||||
/* get device number early */
|
||||
@ -807,11 +807,14 @@ static int peak_usb_create_dev(struct peak_usb_adapter *peak_usb_adapter,
|
||||
|
||||
return 0;
|
||||
|
||||
lbl_free_cmd_buf:
|
||||
lbl_unregister_candev:
|
||||
unregister_candev(netdev);
|
||||
|
||||
lbl_restore_intf_data:
|
||||
usb_set_intfdata(intf, dev->prev_siblings);
|
||||
kfree(dev->cmd_buf);
|
||||
|
||||
lbl_set_intf_data:
|
||||
usb_set_intfdata(intf, dev->prev_siblings);
|
||||
lbl_free_candev:
|
||||
free_candev(netdev);
|
||||
|
||||
return err;
|
||||
|
Loading…
Reference in New Issue
Block a user