• Roland Dreier's avatar
    IB: Remove sysfs files before unregistering device · 9206dff1
    Roland Dreier authored
    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: default avatarJack Morgenstein <jackm@dev.mellanox.co.il>
    Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
    9206dff1
sysfs.c 22.6 KB