wl12xx: Add mutex protection for interface list
The interface list maintained in main.c is not mutex protected. This could cause issues, as the list is accessed from notifier chains. Signed-off-by: Juuso Oikarinen <juuso.oikarinen@nokia.com> Reviewed-by: Luciano Coelho <coelho@ti.com> Signed-off-by: Luciano Coelho <coelho@ti.com>
This commit is contained in:
committed by
Luciano Coelho
parent
1d732e8cf3
commit
f9f774c17e
@@ -339,6 +339,7 @@ static struct platform_device wl1271_device = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static DEFINE_MUTEX(wl_list_mutex);
|
||||||
static LIST_HEAD(wl_list);
|
static LIST_HEAD(wl_list);
|
||||||
|
|
||||||
static int wl1271_dev_notify(struct notifier_block *me, unsigned long what,
|
static int wl1271_dev_notify(struct notifier_block *me, unsigned long what,
|
||||||
@@ -369,10 +370,12 @@ static int wl1271_dev_notify(struct notifier_block *me, unsigned long what,
|
|||||||
return NOTIFY_DONE;
|
return NOTIFY_DONE;
|
||||||
|
|
||||||
wl_temp = hw->priv;
|
wl_temp = hw->priv;
|
||||||
|
mutex_lock(&wl_list_mutex);
|
||||||
list_for_each_entry(wl, &wl_list, list) {
|
list_for_each_entry(wl, &wl_list, list) {
|
||||||
if (wl == wl_temp)
|
if (wl == wl_temp)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
mutex_unlock(&wl_list_mutex);
|
||||||
if (wl != wl_temp)
|
if (wl != wl_temp)
|
||||||
return NOTIFY_DONE;
|
return NOTIFY_DONE;
|
||||||
|
|
||||||
@@ -1390,8 +1393,10 @@ power_off:
|
|||||||
out:
|
out:
|
||||||
mutex_unlock(&wl->mutex);
|
mutex_unlock(&wl->mutex);
|
||||||
|
|
||||||
|
mutex_lock(&wl_list_mutex);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
list_add(&wl->list, &wl_list);
|
list_add(&wl->list, &wl_list);
|
||||||
|
mutex_unlock(&wl_list_mutex);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -1404,7 +1409,9 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl)
|
|||||||
|
|
||||||
wl1271_info("down");
|
wl1271_info("down");
|
||||||
|
|
||||||
|
mutex_lock(&wl_list_mutex);
|
||||||
list_del(&wl->list);
|
list_del(&wl->list);
|
||||||
|
mutex_unlock(&wl_list_mutex);
|
||||||
|
|
||||||
WARN_ON(wl->state != WL1271_STATE_ON);
|
WARN_ON(wl->state != WL1271_STATE_ON);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user