|
@@ -181,9 +181,16 @@ static void add_ref(struct iw_cm_id *cm_id)
|
|
|
static void rem_ref(struct iw_cm_id *cm_id)
|
|
|
{
|
|
|
struct iwcm_id_private *cm_id_priv;
|
|
|
+ int cb_destroy;
|
|
|
+
|
|
|
cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
|
|
|
- if (iwcm_deref_id(cm_id_priv) &&
|
|
|
- test_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags)) {
|
|
|
+
|
|
|
+ /*
|
|
|
+ * Test bit before deref in case the cm_id gets freed on another
|
|
|
+ * thread.
|
|
|
+ */
|
|
|
+ cb_destroy = test_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags);
|
|
|
+ if (iwcm_deref_id(cm_id_priv) && cb_destroy) {
|
|
|
BUG_ON(!list_empty(&cm_id_priv->work_list));
|
|
|
free_cm_id(cm_id_priv);
|
|
|
}
|