Commit c2a2cb03 authored by Eugene Shatokhin's avatar Eugene Shatokhin Committed by Kamal Mostafa

usbnet: Get EVENT_NO_RUNTIME_PM bit before it is cleared

commit f50791ac upstream.

It is needed to check EVENT_NO_RUNTIME_PM bit of dev->flags in
usbnet_stop(), but its value should be read before it is cleared
when dev->flags is set to 0.

The problem was spotted and the fix was provided by
Oliver Neukum <oneukum@suse.de>.
Signed-off-by: default avatarEugene Shatokhin <eugene.shatokhin@rosalab.ru>
Acked-by: default avatarOliver Neukum <oneukum@suse.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
parent e2e0bf4c
...@@ -779,7 +779,7 @@ int usbnet_stop (struct net_device *net) ...@@ -779,7 +779,7 @@ int usbnet_stop (struct net_device *net)
{ {
struct usbnet *dev = netdev_priv(net); struct usbnet *dev = netdev_priv(net);
struct driver_info *info = dev->driver_info; struct driver_info *info = dev->driver_info;
int retval, pm; int retval, pm, mpn;
clear_bit(EVENT_DEV_OPEN, &dev->flags); clear_bit(EVENT_DEV_OPEN, &dev->flags);
netif_stop_queue (net); netif_stop_queue (net);
...@@ -810,6 +810,8 @@ int usbnet_stop (struct net_device *net) ...@@ -810,6 +810,8 @@ int usbnet_stop (struct net_device *net)
usbnet_purge_paused_rxq(dev); usbnet_purge_paused_rxq(dev);
mpn = !test_and_clear_bit(EVENT_NO_RUNTIME_PM, &dev->flags);
/* deferred work (task, timer, softirq) must also stop. /* deferred work (task, timer, softirq) must also stop.
* can't flush_scheduled_work() until we drop rtnl (later), * can't flush_scheduled_work() until we drop rtnl (later),
* else workers could deadlock; so make workers a NOP. * else workers could deadlock; so make workers a NOP.
...@@ -820,8 +822,7 @@ int usbnet_stop (struct net_device *net) ...@@ -820,8 +822,7 @@ int usbnet_stop (struct net_device *net)
if (!pm) if (!pm)
usb_autopm_put_interface(dev->intf); usb_autopm_put_interface(dev->intf);
if (info->manage_power && if (info->manage_power && mpn)
!test_and_clear_bit(EVENT_NO_RUNTIME_PM, &dev->flags))
info->manage_power(dev, 0); info->manage_power(dev, 0);
else else
usb_autopm_put_interface(dev->intf); usb_autopm_put_interface(dev->intf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment