net: mscc: ocelot: fix mutex lock error during ethtool stats read
authorColin Foster <colin.foster@in-advantage.com>
Thu, 10 Feb 2022 15:04:51 +0000 (07:04 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Feb 2022 11:56:32 +0000 (12:56 +0100)
commitd98ba26a4ba9b835887e379193be6cee814c7a52
tree67574651a8a7f7ffce0f707089a846cbcf166452
parent41a8c548d47bcdbbd5e0fa40fbb7c95cc54bcb34
net: mscc: ocelot: fix mutex lock error during ethtool stats read

[ Upstream commit 7fbf6795d127a3b1bb39b0e42579904cf6db1624 ]

An ongoing workqueue populates the stats buffer. At the same time, a user
might query the statistics. While writing to the buffer is mutex-locked,
reading from the buffer wasn't. This could lead to buggy reads by ethtool.

This patch fixes the former blamed commit, but the bug was introduced in
the latter.

Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
Fixes: 1e1caa9735f90 ("ocelot: Clean up stats update deferred work")
Fixes: a556c76adc052 ("net: mscc: Add initial Ocelot switch support")
Reported-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Link: https://lore.kernel.org/all/20220210150451.416845-2-colin.foster@in-advantage.com/
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/mscc/ocelot.c