Commit 755e4ca4 authored by Bryan O'Sullivan's avatar Bryan O'Sullivan Committed by Roland Dreier
Browse files

IB/ipath: fix race with exposing reset file



We were accidentally exposing the "reset" sysfs file more than once
per device.
Signed-off-by: default avatarBryan O'Sullivan <bos@pathscale.com>
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent 254abfd3
...@@ -277,13 +277,14 @@ static int ipath_diag_open(struct inode *in, struct file *fp) ...@@ -277,13 +277,14 @@ static int ipath_diag_open(struct inode *in, struct file *fp)
bail: bail:
spin_unlock_irqrestore(&ipath_devs_lock, flags); spin_unlock_irqrestore(&ipath_devs_lock, flags);
mutex_unlock(&ipath_mutex);
/* Only expose a way to reset the device if we /* Only expose a way to reset the device if we
make it into diag mode. */ make it into diag mode. */
if (ret == 0) if (ret == 0)
ipath_expose_reset(&dd->pcidev->dev); ipath_expose_reset(&dd->pcidev->dev);
mutex_unlock(&ipath_mutex);
return ret; return ret;
} }
......
...@@ -711,10 +711,22 @@ static struct attribute_group dev_attr_group = { ...@@ -711,10 +711,22 @@ static struct attribute_group dev_attr_group = {
* enters diag mode. A device reset is quite likely to crash the * enters diag mode. A device reset is quite likely to crash the
* machine entirely, so we don't want to normally make it * machine entirely, so we don't want to normally make it
* available. * available.
*
* Called with ipath_mutex held.
*/ */
int ipath_expose_reset(struct device *dev) 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) int ipath_driver_create_group(struct device_driver *drv)
......
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