History

lan78xx: Crash in lan78xx_writ_reg (Workqueue: events lan78xx_deferred_multicast_write)

Description: Crash was reported with syzkaller pointing to lan78xx_write_reg routine. Root-cause: Proper cleanup of workqueues and init/setup routines was not happening in failure conditions. Fix: Handled the error conditions by cleaning up the queues and init/setup routines.

Raghuram Chary J committed 8 years ago

Commit 2d2d99e1 parent 020295d1 file · +21 −2Browse files

Unified · Split

drivers/net/usb/lan78xx.c+21−2
@@ -2873,8 +2873,7 @@ static int lan78xx_bind(struct lan78xx_net *dev, struct usb_interface *intf) · 2872 unmodified lines
28732873 if (ret < 0) {
28742874 netdev_warn(dev->net,
28752875 "lan78xx_setup_irq_domain() failed : %d", ret);
2876− kfree(pdata);
2877− return ret;
2876+ goto out1;
28782877 }
28792878
28802879 dev->net->hard_header_len += TX_OVERHEAD;
@@ -2882,14 +2881,32 @@ static int lan78xx_bind(struct lan78xx_net *dev, struct usb_interface *intf) · 1 unmodified line
28822881
28832882 /* Init all registers */
28842883 ret = lan78xx_reset(dev);
2884+ if (ret) {
2885+ netdev_warn(dev->net, "Registers INIT FAILED....");
2886+ goto out2;
2887+ }
28852888
28862889 ret = lan78xx_mdio_init(dev);
2890+ if (ret) {
2891+ netdev_warn(dev->net, "MDIO INIT FAILED.....");
2892+ goto out2;
2893+ }
28872894
28882895 dev->net->flags |= IFF_MULTICAST;
28892896
28902897 pdata->wol = WAKE_MAGIC;
28912898
28922899 return ret;
2900+
2901+out2:
2902+ lan78xx_remove_irq_domain(dev);
2903+
2904+out1:
2905+ netdev_warn(dev->net, "Bind routine FAILED");
2906+ cancel_work_sync(&pdata->set_multicast);
2907+ cancel_work_sync(&pdata->set_vlan);
2908+ kfree(pdata);
2909+ return ret;
28932910 }
28942911
28952912 static void lan78xx_unbind(struct lan78xx_net *dev, struct usb_interface *intf)
@@ -2901,6 +2918,8 @@ static void lan78xx_unbind(struct lan78xx_net *dev, struct usb_interface *intf) · 5 unmodified lines
29012918 lan78xx_remove_mdio(dev);
29022919
29032920 if (pdata) {
2921+ cancel_work_sync(&pdata->set_multicast);
2922+ cancel_work_sync(&pdata->set_vlan);
29042923 netif_dbg(dev, ifdown, dev->net, "free pdata");
29052924 kfree(pdata);
29062925 pdata = NULL;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t