staging: unisys: visornic - ensure proper net locking in tx reset logic
authorTim Sell <Timothy.Sell@unisys.com>
Fri, 24 Jul 2015 16:00:22 +0000 (12:00 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 24 Jul 2015 20:43:37 +0000 (13:43 -0700)
visornic tx reset handling is done asynchronously via a workqueue in
visornic_timeout_reset().  As a result, it needs to use rtnl_lock() /
rtnl_unlock() to lock against possible simultaneous close() of the network
device.

(I consulted the bnx2 driver as a model here, as that driver also does
its tx reset handling asynchronously, just like visornic does.  See
bnx2_tx_timeout() and bnx2_reset_task().)

Signed-off-by: Tim Sell <Timothy.Sell@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/unisys/visornic/visornic_main.c

index 9d10b85ac7eb27342508292ffdaf276e6877817e..ec38b51eca010567f22987ebdcf2c8d3c6a479a9 100644 (file)
@@ -731,6 +731,12 @@ visornic_timeout_reset(struct work_struct *work)
        devdata = container_of(work, struct visornic_devdata, timeout_reset);
        netdev = devdata->netdev;
 
+       rtnl_lock();
+       if (!netif_running(netdev)) {
+               rtnl_unlock();
+               return;
+       }
+
        response = visornic_disable_with_timeout(netdev,
                                                 VISORNIC_INFINITE_RSP_WAIT);
        if (response)
@@ -741,10 +747,13 @@ visornic_timeout_reset(struct work_struct *work)
        if (response)
                goto call_serverdown;
 
+       rtnl_unlock();
+
        return;
 
 call_serverdown:
        visornic_serverdown(devdata, NULL);
+       rtnl_unlock();
 }
 
 /**