diff options
author | Parav Pandit <parav@nvidia.com> | 2020-08-21 22:12:21 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-08-24 16:02:47 -0700 |
commit | 5d080b5064a1d2429071276dfc7588b2eecbc02f (patch) | |
tree | 939207f4af7fee2dadae5b20d518da41adecce97 /net | |
parent | 79604c5de2c30b67079b9bfff48dae4bbd05ec4f (diff) | |
download | lwn-5d080b5064a1d2429071276dfc7588b2eecbc02f.tar.gz lwn-5d080b5064a1d2429071276dfc7588b2eecbc02f.zip |
devlink: Protect devlink port list traversal
Cited patch in fixes tag misses to protect port list traversal
while traversing per port reporter list.
Protect it using devlink instance lock.
Fixes: f4f541660121 ("devlink: Implement devlink health reporters on per-port basis")
Signed-off-by: Parav Pandit <parav@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/devlink.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/net/core/devlink.c b/net/core/devlink.c index 9b01f7245fd8..58c8bb07fa19 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -5895,6 +5895,7 @@ devlink_nl_cmd_health_reporter_get_dumpit(struct sk_buff *msg, list_for_each_entry(devlink, &devlink_list, list) { if (!net_eq(devlink_net(devlink), sock_net(msg->sk))) continue; + mutex_lock(&devlink->lock); list_for_each_entry(port, &devlink->port_list, list) { mutex_lock(&port->reporters_lock); list_for_each_entry(reporter, &port->reporter_list, list) { @@ -5909,12 +5910,14 @@ devlink_nl_cmd_health_reporter_get_dumpit(struct sk_buff *msg, NLM_F_MULTI); if (err) { mutex_unlock(&port->reporters_lock); + mutex_unlock(&devlink->lock); goto out; } idx++; } mutex_unlock(&port->reporters_lock); } + mutex_unlock(&devlink->lock); } out: mutex_unlock(&devlink_mutex); |