diff options
author | Haggai Eran <haggaie@mellanox.com> | 2015-07-30 10:50:14 -0400 |
---|---|---|
committer | Doug Ledford <dledford@redhat.com> | 2015-08-30 15:48:21 -0400 |
commit | 7c1eb45a22d76bb99236e7485958f87ef7c449cf (patch) | |
tree | 9c4d29b17d17e99f6cfa7ccc1a542d13f9bb4269 /drivers/infiniband/core/multicast.c | |
parent | 5aa44bb90f047662c12c44be1b6de454658632d0 (diff) |
IB/core: lock client data with lists_rwsem
An ib_client callback that is called with the lists_rwsem locked only for
read is protected from changes to the IB client lists, but not from
ib_unregister_device() freeing its client data. This is because
ib_unregister_device() will remove the device from the device list with
lists_rwsem locked for write, but perform the rest of the cleanup,
including the call to remove() without that lock.
Mark client data that is undergoing de-registration with a new going_down
flag in the client data context. Lock the client data list with lists_rwsem
for write in addition to using the spinlock, so that functions calling the
callback would be able to lock only lists_rwsem for read and let callbacks
sleep.
Since ib_unregister_client() now marks the client data context, no need for
remove() to search the context again, so pass the client data directly to
remove() callbacks.
Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Signed-off-by: Haggai Eran <haggaie@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'drivers/infiniband/core/multicast.c')
-rw-r--r-- | drivers/infiniband/core/multicast.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/infiniband/core/multicast.c b/drivers/infiniband/core/multicast.c index 2cb865c7ce7a..d38d8b2b2979 100644 --- a/drivers/infiniband/core/multicast.c +++ b/drivers/infiniband/core/multicast.c | |||
@@ -43,7 +43,7 @@ | |||
43 | #include "sa.h" | 43 | #include "sa.h" |
44 | 44 | ||
45 | static void mcast_add_one(struct ib_device *device); | 45 | static void mcast_add_one(struct ib_device *device); |
46 | static void mcast_remove_one(struct ib_device *device); | 46 | static void mcast_remove_one(struct ib_device *device, void *client_data); |
47 | 47 | ||
48 | static struct ib_client mcast_client = { | 48 | static struct ib_client mcast_client = { |
49 | .name = "ib_multicast", | 49 | .name = "ib_multicast", |
@@ -840,13 +840,12 @@ static void mcast_add_one(struct ib_device *device) | |||
840 | ib_register_event_handler(&dev->event_handler); | 840 | ib_register_event_handler(&dev->event_handler); |
841 | } | 841 | } |
842 | 842 | ||
843 | static void mcast_remove_one(struct ib_device *device) | 843 | static void mcast_remove_one(struct ib_device *device, void *client_data) |
844 | { | 844 | { |
845 | struct mcast_device *dev; | 845 | struct mcast_device *dev = client_data; |
846 | struct mcast_port *port; | 846 | struct mcast_port *port; |
847 | int i; | 847 | int i; |
848 | 848 | ||
849 | dev = ib_get_client_data(device, &mcast_client); | ||
850 | if (!dev) | 849 | if (!dev) |
851 | return; | 850 | return; |
852 | 851 | ||