]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net: mdiobus: Disable preemption upon u64_stats update
authorAhmed S. Darwish <a.darwish@linutronix.de>
Wed, 3 Jun 2020 14:49:47 +0000 (16:49 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 24 Jun 2020 15:48:30 +0000 (17:48 +0200)
[ Upstream commit c7e261d81783387a0502878cd229327e7c54322e ]

The u64_stats mechanism uses sequence counters to protect against 64-bit
values tearing on 32-bit architectures. Updating u64_stats is thus a
sequence counter write side critical section where preemption must be
disabled.

For mdiobus_stats_acct(), disable preemption upon the u64_stats update.
It is called from process context through mdiobus_read() and
mdiobus_write().

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/phy/mdio_bus.c

index 7a4eb3f2cb743a007903edaf8362eaee75602870..a1a4dee2a033a75893669431f99f8b0bc1ad8dd5 100644 (file)
@@ -757,6 +757,7 @@ EXPORT_SYMBOL(mdiobus_scan);
 
 static void mdiobus_stats_acct(struct mdio_bus_stats *stats, bool op, int ret)
 {
+       preempt_disable();
        u64_stats_update_begin(&stats->syncp);
 
        u64_stats_inc(&stats->transfers);
@@ -771,6 +772,7 @@ static void mdiobus_stats_acct(struct mdio_bus_stats *stats, bool op, int ret)
                u64_stats_inc(&stats->writes);
 out:
        u64_stats_update_end(&stats->syncp);
+       preempt_enable();
 }
 
 /**