diff options
author | Roland Dreier <rolandd@cisco.com> | 2009-02-26 00:27:46 +0300 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2009-02-26 00:27:46 +0300 |
commit | 9206dff15705267c19f8fed391c4fb95975540a3 (patch) | |
tree | fc9722069f10675ed77f2dd90e52daef5230be33 /drivers/infiniband/core/sysfs.c | |
parent | f3b8436ad9a8ad36b3c9fa1fe030c7f38e5d3d0b (diff) | |
download | linux-9206dff15705267c19f8fed391c4fb95975540a3.tar.xz |
IB: Remove sysfs files before unregistering device
Move the ib_device_unregister_sysfs() call from ib_dealloc_device() to
ib_unregister_device(). The old code allows device unregister to
proceed even if some sysfs files are open, which leaves a window where
userspace can open a file before a device is removed but then end up
reading the file after the device is removed, which leads to various
kernel crashes either because the device data structure is freed or
because the low-level driver code is gone after module removal.
By not returning from ib_unregister_device() until after all sysfs
entries are removed, we make sure that data structures and/or module
code is not freed until after all sysfs access is done.
Reported-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/core/sysfs.c')
-rw-r--r-- | drivers/infiniband/core/sysfs.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index b43f7d3682d3..5270aeb56e9e 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c @@ -848,6 +848,9 @@ void ib_device_unregister_sysfs(struct ib_device *device) struct kobject *p, *t; struct ib_port *port; + /* Hold kobject until ib_dealloc_device() */ + kobject_get(&device->dev.kobj); + list_for_each_entry_safe(p, t, &device->port_list, entry) { list_del(&p->entry); port = container_of(p, struct ib_port, kobj); |