mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-21 14:11:20 +00:00
devlink: Protect rate list with lock while switching modes
Devlink eswitch set command doesn't hold devlink->lock, which makes
possible race condition between rate list traversing and others devlink
rate KAPI calls, like devlink_rate_nodes_destroy().
Hold devlink lock while traversing the list.
Fixes: a8ecb93ef0
("devlink: Introduce rate nodes")
Signed-off-by: Dmytro Linkin <dlinkin@nvidia.com>
Reviewed-by: Parav Pandit <parav@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
ff99324ded
commit
a3e5e5797f
1 changed files with 4 additions and 0 deletions
|
@ -2710,11 +2710,15 @@ static int devlink_rate_nodes_check(struct devlink *devlink, u16 mode,
|
||||||
{
|
{
|
||||||
struct devlink_rate *devlink_rate;
|
struct devlink_rate *devlink_rate;
|
||||||
|
|
||||||
|
/* Take the lock to sync with devlink_rate_nodes_destroy() */
|
||||||
|
mutex_lock(&devlink->lock);
|
||||||
list_for_each_entry(devlink_rate, &devlink->rate_list, list)
|
list_for_each_entry(devlink_rate, &devlink->rate_list, list)
|
||||||
if (devlink_rate_is_node(devlink_rate)) {
|
if (devlink_rate_is_node(devlink_rate)) {
|
||||||
|
mutex_unlock(&devlink->lock);
|
||||||
NL_SET_ERR_MSG_MOD(extack, "Rate node(s) exists.");
|
NL_SET_ERR_MSG_MOD(extack, "Rate node(s) exists.");
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
|
mutex_unlock(&devlink->lock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue