Skip to content

Commit

Permalink
IB/ipath: fix race with exposing reset file
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Bryan O'Sullivan authored and Roland Dreier committed May 1, 2006
1 parent 254abfd commit 755e4ca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion drivers/infiniband/hw/ipath/ipath_diag.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
14 changes: 13 additions & 1 deletion drivers/infiniband/hw/ipath/ipath_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 755e4ca

Please sign in to comment.