diff options
Diffstat (limited to 'drivers/infiniband/core/iwcm.c')
-rw-r--r-- | drivers/infiniband/core/iwcm.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/infiniband/core/iwcm.c b/drivers/infiniband/core/iwcm.c index c47c2034ca71..0717940ec3b5 100644 --- a/drivers/infiniband/core/iwcm.c +++ b/drivers/infiniband/core/iwcm.c | |||
@@ -181,9 +181,16 @@ static void add_ref(struct iw_cm_id *cm_id) | |||
181 | static void rem_ref(struct iw_cm_id *cm_id) | 181 | static void rem_ref(struct iw_cm_id *cm_id) |
182 | { | 182 | { |
183 | struct iwcm_id_private *cm_id_priv; | 183 | struct iwcm_id_private *cm_id_priv; |
184 | int cb_destroy; | ||
185 | |||
184 | cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); | 186 | cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); |
185 | if (iwcm_deref_id(cm_id_priv) && | 187 | |
186 | test_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags)) { | 188 | /* |
189 | * Test bit before deref in case the cm_id gets freed on another | ||
190 | * thread. | ||
191 | */ | ||
192 | cb_destroy = test_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags); | ||
193 | if (iwcm_deref_id(cm_id_priv) && cb_destroy) { | ||
187 | BUG_ON(!list_empty(&cm_id_priv->work_list)); | 194 | BUG_ON(!list_empty(&cm_id_priv->work_list)); |
188 | free_cm_id(cm_id_priv); | 195 | free_cm_id(cm_id_priv); |
189 | } | 196 | } |