netvsc: fix deadlock betwen link status and removal
authorstephen hemminger <stephen@networkplumber.org>
Thu, 24 Aug 2017 23:49:16 +0000 (16:49 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 25 Aug 2017 04:59:08 +0000 (21:59 -0700)
There is a deadlock possible when canceling the link status
delayed work queue. The removal process is run with RTNL held,
and the link status callback is acquring RTNL.

Resolve the issue by using trylock and rescheduling.
If cancel is in process, that block it from happening.

Fixes: 122a5f6410f4 ("staging: hv: use delayed_work for netvsc_send_garp()")
Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/hyperv/netvsc_drv.c

index 0d78727f1a14dd9c4ae301f053769437cbe4eb3b..d91cbc6c3ca4eee43090bccc70c76b9a9d1fbb85 100644 (file)
@@ -1269,7 +1269,12 @@ static void netvsc_link_change(struct work_struct *w)
        bool notify = false, reschedule = false;
        unsigned long flags, next_reconfig, delay;
 
-       rtnl_lock();
+       /* if changes are happening, comeback later */
+       if (!rtnl_trylock()) {
+               schedule_delayed_work(&ndev_ctx->dwork, LINKCHANGE_INT);
+               return;
+       }
+
        net_device = rtnl_dereference(ndev_ctx->nvdev);
        if (!net_device)
                goto out_unlock;