aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorHaggai Eran <haggaie@mellanox.com>2015-07-30 10:50:14 -0400
committerDoug Ledford <dledford@redhat.com>2015-08-30 15:48:21 -0400
commit7c1eb45a22d76bb99236e7485958f87ef7c449cf (patch)
tree9c4d29b17d17e99f6cfa7ccc1a542d13f9bb4269 /net
parent5aa44bb90f047662c12c44be1b6de454658632d0 (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 'net')
-rw-r--r--net/rds/ib.c5
-rw-r--r--net/rds/iw.c5
2 files changed, 4 insertions, 6 deletions
diff --git a/net/rds/ib.c b/net/rds/ib.c
index ba2dffeff608..348ac37c1161 100644
--- a/net/rds/ib.c
+++ b/net/rds/ib.c
@@ -230,11 +230,10 @@ struct rds_ib_device *rds_ib_get_client_data(struct ib_device *device)
230 * 230 *
231 * This can be called at any time and can be racing with any other RDS path. 231 * This can be called at any time and can be racing with any other RDS path.
232 */ 232 */
233static void rds_ib_remove_one(struct ib_device *device) 233static void rds_ib_remove_one(struct ib_device *device, void *client_data)
234{ 234{
235 struct rds_ib_device *rds_ibdev; 235 struct rds_ib_device *rds_ibdev = client_data;
236 236
237 rds_ibdev = ib_get_client_data(device, &rds_ib_client);
238 if (!rds_ibdev) 237 if (!rds_ibdev)
239 return; 238 return;
240 239
diff --git a/net/rds/iw.c b/net/rds/iw.c
index 589935661d66..7cc2f32a0cb3 100644
--- a/net/rds/iw.c
+++ b/net/rds/iw.c
@@ -125,12 +125,11 @@ free_attr:
125 kfree(dev_attr); 125 kfree(dev_attr);
126} 126}
127 127
128static void rds_iw_remove_one(struct ib_device *device) 128static void rds_iw_remove_one(struct ib_device *device, void *client_data)
129{ 129{
130 struct rds_iw_device *rds_iwdev; 130 struct rds_iw_device *rds_iwdev = client_data;
131 struct rds_iw_cm_id *i_cm_id, *next; 131 struct rds_iw_cm_id *i_cm_id, *next;
132 132
133 rds_iwdev = ib_get_client_data(device, &rds_iw_client);
134 if (!rds_iwdev) 133 if (!rds_iwdev)
135 return; 134 return;
136 135