aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorUjjal Roy <royujjal@gmail.com>2013-11-14 22:10:42 -0500
committerJohn W. Linville <linville@tuxdriver.com>2013-11-15 14:29:32 -0500
commit353d2a69ea2607acd80c6bea7da2ab9bb65d2622 (patch)
treed1628b0f620d60ea8afbd531ca2373a20b5a7732 /drivers/net
parent3c59e328eb4ff23781bfa4cfc9f6f496003bf8b9 (diff)
mwifiex: fix issues in driver unload path for USB chipsets
1) After driver load failure, clear 'card->adapter' instead of card pointer so that card specific cleanup is performed later when user unloads the driver. 2) Clear usb_card pointer in disconnect handler to avoid invalid memory access when user unloads the driver after removing the card. Signed-off-by: Ujjal Roy <royujjal@gmail.com> Signed-off-by: Amitkumar Karwar <akarwar@marvell.com> Signed-off-by: Bing Zhao <bzhao@marvell.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/mwifiex/usb.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/drivers/net/wireless/mwifiex/usb.c b/drivers/net/wireless/mwifiex/usb.c
index 1c70b8d09227..edf5b7a24900 100644
--- a/drivers/net/wireless/mwifiex/usb.c
+++ b/drivers/net/wireless/mwifiex/usb.c
@@ -350,7 +350,6 @@ static int mwifiex_usb_probe(struct usb_interface *intf,
350 350
351 card->udev = udev; 351 card->udev = udev;
352 card->intf = intf; 352 card->intf = intf;
353 usb_card = card;
354 353
355 pr_debug("info: bcdUSB=%#x Device Class=%#x SubClass=%#x Protocol=%#x\n", 354 pr_debug("info: bcdUSB=%#x Device Class=%#x SubClass=%#x Protocol=%#x\n",
356 udev->descriptor.bcdUSB, udev->descriptor.bDeviceClass, 355 udev->descriptor.bcdUSB, udev->descriptor.bDeviceClass,
@@ -525,25 +524,28 @@ static int mwifiex_usb_resume(struct usb_interface *intf)
525static void mwifiex_usb_disconnect(struct usb_interface *intf) 524static void mwifiex_usb_disconnect(struct usb_interface *intf)
526{ 525{
527 struct usb_card_rec *card = usb_get_intfdata(intf); 526 struct usb_card_rec *card = usb_get_intfdata(intf);
528 struct mwifiex_adapter *adapter;
529 527
530 if (!card || !card->adapter) { 528 if (!card) {
531 pr_err("%s: card or card->adapter is NULL\n", __func__); 529 pr_err("%s: card is NULL\n", __func__);
532 return; 530 return;
533 } 531 }
534 532
535 adapter = card->adapter;
536 if (!adapter->priv_num)
537 return;
538
539 mwifiex_usb_free(card); 533 mwifiex_usb_free(card);
540 534
541 dev_dbg(adapter->dev, "%s: removing card\n", __func__); 535 if (card->adapter) {
542 mwifiex_remove_card(adapter, &add_remove_card_sem); 536 struct mwifiex_adapter *adapter = card->adapter;
537
538 if (!adapter->priv_num)
539 return;
540
541 dev_dbg(adapter->dev, "%s: removing card\n", __func__);
542 mwifiex_remove_card(adapter, &add_remove_card_sem);
543 }
543 544
544 usb_set_intfdata(intf, NULL); 545 usb_set_intfdata(intf, NULL);
545 usb_put_dev(interface_to_usbdev(intf)); 546 usb_put_dev(interface_to_usbdev(intf));
546 kfree(card); 547 kfree(card);
548 usb_card = NULL;
547 549
548 return; 550 return;
549} 551}
@@ -754,6 +756,7 @@ static int mwifiex_register_dev(struct mwifiex_adapter *adapter)
754 card->adapter = adapter; 756 card->adapter = adapter;
755 adapter->dev = &card->udev->dev; 757 adapter->dev = &card->udev->dev;
756 strcpy(adapter->fw_name, USB8797_DEFAULT_FW_NAME); 758 strcpy(adapter->fw_name, USB8797_DEFAULT_FW_NAME);
759 usb_card = card;
757 760
758 return 0; 761 return 0;
759} 762}
@@ -762,7 +765,7 @@ static void mwifiex_unregister_dev(struct mwifiex_adapter *adapter)
762{ 765{
763 struct usb_card_rec *card = (struct usb_card_rec *)adapter->card; 766 struct usb_card_rec *card = (struct usb_card_rec *)adapter->card;
764 767
765 usb_set_intfdata(card->intf, NULL); 768 card->adapter = NULL;
766} 769}
767 770
768static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter, 771static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter,
@@ -1004,7 +1007,7 @@ static void mwifiex_usb_cleanup_module(void)
1004 if (!down_interruptible(&add_remove_card_sem)) 1007 if (!down_interruptible(&add_remove_card_sem))
1005 up(&add_remove_card_sem); 1008 up(&add_remove_card_sem);
1006 1009
1007 if (usb_card) { 1010 if (usb_card && usb_card->adapter) {
1008 struct mwifiex_adapter *adapter = usb_card->adapter; 1011 struct mwifiex_adapter *adapter = usb_card->adapter;
1009 int i; 1012 int i;
1010 1013