]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
IB/ipath: fix race with exposing reset file
authorBryan O'Sullivan <bos@pathscale.com>
Mon, 24 Apr 2006 21:22:57 +0000 (14:22 -0700)
committerRoland Dreier <rolandd@cisco.com>
Mon, 1 May 2006 19:14:11 +0000 (12:14 -0700)
We were accidentally exposing the "reset" sysfs file more than once
per device.

Signed-off-by: Bryan O'Sullivan <bos@pathscale.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/hw/ipath/ipath_diag.c
drivers/infiniband/hw/ipath/ipath_sysfs.c

index 7d3fb6996b41d6fb6aecf589b2ef2bcddbe5588e..28ddceb260e895dd88863e5995e4dbb6df1dbd9e 100644 (file)
@@ -277,13 +277,14 @@ static int ipath_diag_open(struct inode *in, struct file *fp)
 
 bail:
        spin_unlock_irqrestore(&ipath_devs_lock, flags);
-       mutex_unlock(&ipath_mutex);
 
        /* Only expose a way to reset the device if we
           make it into diag mode. */
        if (ret == 0)
                ipath_expose_reset(&dd->pcidev->dev);
 
+       mutex_unlock(&ipath_mutex);
+
        return ret;
 }
 
index 32acd8048b499809b1f8988de48dc6499365aea7..f323791cc49513d2b25be8238f68f6538dda330b 100644 (file)
@@ -711,10 +711,22 @@ static struct attribute_group dev_attr_group = {
  * enters diag mode.  A device reset is quite likely to crash the
  * machine entirely, so we don't want to normally make it
  * available.
+ *
+ * Called with ipath_mutex held.
  */
 int ipath_expose_reset(struct device *dev)
 {
-       return device_create_file(dev, &dev_attr_reset);
+       static int exposed;
+       int ret;
+
+       if (!exposed) {
+               ret = device_create_file(dev, &dev_attr_reset);
+               exposed = 1;
+       }
+       else
+               ret = 0;
+
+       return ret;
 }
 
 int ipath_driver_create_group(struct device_driver *drv)