]> bbs.cooldavid.org Git - net-next-2.6.git/commit
IB: Remove sysfs files before unregistering device
authorRoland Dreier <rolandd@cisco.com>
Wed, 25 Feb 2009 21:27:46 +0000 (13:27 -0800)
committerRoland Dreier <rolandd@cisco.com>
Wed, 25 Feb 2009 21:27:46 +0000 (13:27 -0800)
commit9206dff15705267c19f8fed391c4fb95975540a3
treefc9722069f10675ed77f2dd90e52daef5230be33
parentf3b8436ad9a8ad36b3c9fa1fe030c7f38e5d3d0b
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>
drivers/infiniband/core/device.c
drivers/infiniband/core/sysfs.c