Fixed disconnect bug by removing erroneous use of kfree()
PATCH 1/1 Fixed disconnect bug by removing erroneous use of kfree()
From b0a5029680d544faf07bcf636084b3fcafe59953 Mon Sep 17 00:00:00 2001
From: Maximilian Schneider <[email protected]>
Date: Tue, 23 Feb 2016 01:03:53 +0000
Subject: [PATCH 1/1] Fixed disconnect bug by removing erroneous use of kfree()
and revised disconnect routine.
Signed-off-by Maximilian Schneider <[email protected]>
--- drivers/net/can/usb/gs_usb.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)
drivers/net/can/usb/gs_usb.c +12 -13
@@ -826,9 +826,8 @@ static struct gs_can *gs_make_candev(unsigned int channel, struct usb_interfacestatic void gs_destroy_candev (struct gs_can *dev) {unregister_candev (dev->netdev); -free_candev (dev->netdev);usb_kill_anchored_urbs (&dev->tx_submitted); -kfree (dev); +free_candev (dev->netdev); }static int gs_usb_probe (struct usb_interface *intf,const struct usb_device_id *id)
@@ -913,12 +912,15 @@ static int gs_usb_probe(struct usb_interface *intf, const struct usb_device_id *for (i =0 ; i < icount; i++) { dev->canch[i] =gs_make_candev (i, intf);if (IS_ERR_OR_NULL (dev->canch[i])) { +/* save error code to return later */ + rc =PTR_ERR (dev->canch[i]); +/* on failure destroy previously created candevs */ icount = i; -for (i =0 ; i < icount; i++) { +for (i =0 ; i < icount; i++)gs_destroy_candev (dev->canch[i]); - dev->canch[i] =NULL ; - } + +usb_kill_anchored_urbs (&dev->rx_submitted);kfree (dev);return rc; }
@@ -939,16 +941,12 @@ static void gs_usb_disconnect(struct usb_interface *intf)return ; } -for (i =0 ; i <GS_MAX_INTF ; i++) { -struct gs_can *can = dev->canch[i]; - -if (!can) -continue ; - -gs_destroy_candev (can); - } +for (i =0 ; i <GS_MAX_INTF ; i++) +if (dev->canch[i]) +gs_destroy_candev (dev->canch[i]);usb_kill_anchored_urbs (&dev->rx_submitted); +kfree (dev); }static const struct usb_device_id gs_usb_table[] = {
@@ -972,3 +970,4 @@ MODULE_DESCRIPTION("Socket CAN device driver for Geschwister Schneider Technologie-, " "Entwicklungs- und Vertriebs UG. USB2.0 to CAN interfaces.");MODULE_LICENSE ("GPL v2" ); +
Signature · 1 line
2.1.4
Marc Kleine-Budde
maintainerQuoted 5 lines · Maximilain Schneider
From
b0a5029680d544faf07bcf636084b3fcafe59953Mon Sep 17 00:00:00 2001
From: Maximilian Schneider <[email protected]>
Date: Tue, 23 Feb 2016 01:03:53 +0000
Subject: [PATCH 1/1] Fixed disconnect bug by removing erroneous use ofkfree()
and revised disconnect routine.
Can you please probive a patch description, too. No need to resend the patch, I'll add it while applying the patch.
Quoted 1 line
Signed-off-by Maximilian Schneider <[email protected]>
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |