mirror of
https://github.com/torvalds/linux.git
synced 2024-11-11 06:31:49 +00:00
can: peak: fix bad memory access and free sequence
Fix for bad memory access while disconnecting. netdev is freed before private data free, and dev is accessed after freeing netdev. This makes a slub problem, and it raise kernel oops with slub debugger config. Signed-off-by: Jiho Chu <jiho.chu@samsung.com> Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
parent
ec988ad78e
commit
b67d0dd7d0
@ -870,23 +870,25 @@ lbl_free_candev:
|
||||
static void peak_usb_disconnect(struct usb_interface *intf)
|
||||
{
|
||||
struct peak_usb_device *dev;
|
||||
struct peak_usb_device *dev_prev_siblings;
|
||||
|
||||
/* unregister as many netdev devices as siblings */
|
||||
for (dev = usb_get_intfdata(intf); dev; dev = dev->prev_siblings) {
|
||||
for (dev = usb_get_intfdata(intf); dev; dev = dev_prev_siblings) {
|
||||
struct net_device *netdev = dev->netdev;
|
||||
char name[IFNAMSIZ];
|
||||
|
||||
dev_prev_siblings = dev->prev_siblings;
|
||||
dev->state &= ~PCAN_USB_STATE_CONNECTED;
|
||||
strncpy(name, netdev->name, IFNAMSIZ);
|
||||
|
||||
unregister_netdev(netdev);
|
||||
free_candev(netdev);
|
||||
|
||||
kfree(dev->cmd_buf);
|
||||
dev->next_siblings = NULL;
|
||||
if (dev->adapter->dev_free)
|
||||
dev->adapter->dev_free(dev);
|
||||
|
||||
free_candev(netdev);
|
||||
dev_info(&intf->dev, "%s removed\n", name);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user