summaryrefslogtreecommitdiffstats
path: root/net/core/net-sysfs.c
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2024-02-13 06:32:39 +0000
committerDavid S. Miller <davem@davemloft.net>2024-02-14 11:20:13 +0000
commit004d138364fd10dd5ff8ceb54cfdc2d792a7b338 (patch)
tree19491864f7a5306175afb03f896047725ffe281f /net/core/net-sysfs.c
parentc7d52737e7ebd31cc5fef46380d94b58becf9479 (diff)
downloadlinux-stable-004d138364fd10dd5ff8ceb54cfdc2d792a7b338.tar.gz
linux-stable-004d138364fd10dd5ff8ceb54cfdc2d792a7b338.tar.bz2
linux-stable-004d138364fd10dd5ff8ceb54cfdc2d792a7b338.zip
net-sysfs: convert dev->operstate reads to lockless ones
operstate_show() can omit dev_base_lock acquisition only to read dev->operstate. Annotate accesses to dev->operstate. Writers still acquire dev_base_lock for mutual exclusion. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/net-sysfs.c')
-rw-r--r--net/core/net-sysfs.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 23ef2df549c3..c5d164b8c6bf 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -325,11 +325,9 @@ static ssize_t operstate_show(struct device *dev,
const struct net_device *netdev = to_net_dev(dev);
unsigned char operstate;
- read_lock(&dev_base_lock);
- operstate = netdev->operstate;
+ operstate = READ_ONCE(netdev->operstate);
if (!netif_running(netdev))
operstate = IF_OPER_DOWN;
- read_unlock(&dev_base_lock);
if (operstate >= ARRAY_SIZE(operstates))
return -EINVAL; /* should not happen */