]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
net: cadence: macb: Synchronize stats calculations
authorSean Anderson <sean.anderson@linux.dev>
Thu, 20 Feb 2025 16:29:50 +0000 (11:29 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 7 Mar 2025 17:25:30 +0000 (18:25 +0100)
commitab52446831a7b77408595b71c38b10f12a37c544
tree7172ee3f989baaf2a31e3ad6eace8c5381c4a605
parent5353fd89663c48f56bdff975c562cfe78b1a2e4c
net: cadence: macb: Synchronize stats calculations

[ Upstream commit fa52f15c745ce55261b92873676f64f7348cfe82 ]

Stats calculations involve a RMW to add the stat update to the existing
value. This is currently not protected by any synchronization mechanism,
so data races are possible. Add a spinlock to protect the update. The
reader side could be protected using u64_stats, but we would still need
a spinlock for the update side anyway. And we always do an update
immediately before reading the stats anyway.

Fixes: 89e5785fc8a6 ("[PATCH] Atmel MACB ethernet driver")
Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
Link: https://patch.msgid.link/20250220162950.95941-1-sean.anderson@linux.dev
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/cadence/macb.h
drivers/net/ethernet/cadence/macb_main.c