netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: pxa168_eth: Fix a potential data race in pxa168_eth_remove
@ 2021-03-10  8:10 Pavel Andrianov
  2021-03-10 23:40 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Andrianov @ 2021-03-10  8:10 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski
  Cc: Pavel Andrianov, netdev, linux-kernel, ldv-project

pxa168_eth_remove() firstly calls unregister_netdev(),
then cancels a timeout work. unregister_netdev() shuts down a device
interface and removes it from the kernel tables. If the timeout occurs
in parallel, the timeout work (pxa168_eth_tx_timeout_task) performs stop
and open of the device. It may lead to an inconsistent state and memory
leaks.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Pavel Andrianov <andrianov@ispras.ru>
---
 drivers/net/ethernet/marvell/pxa168_eth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c b/drivers/net/ethernet/marvell/pxa168_eth.c
index d1e4d42e497d..3712e1786091 100644
--- a/drivers/net/ethernet/marvell/pxa168_eth.c
+++ b/drivers/net/ethernet/marvell/pxa168_eth.c
@@ -1544,8 +1544,8 @@ static int pxa168_eth_remove(struct platform_device *pdev)
 	clk_disable_unprepare(pep->clk);
 	mdiobus_unregister(pep->smi_bus);
 	mdiobus_free(pep->smi_bus);
-	unregister_netdev(dev);
 	cancel_work_sync(&pep->tx_timeout_task);
+	unregister_netdev(dev);
 	free_netdev(dev);
 	return 0;
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: pxa168_eth: Fix a potential data race in pxa168_eth_remove
  2021-03-10  8:10 [PATCH] net: pxa168_eth: Fix a potential data race in pxa168_eth_remove Pavel Andrianov
@ 2021-03-10 23:40 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-03-10 23:40 UTC (permalink / raw)
  To: Pavel Andrianov; +Cc: davem, kuba, netdev, linux-kernel, ldv-project

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Wed, 10 Mar 2021 11:10:46 +0300 you wrote:
> pxa168_eth_remove() firstly calls unregister_netdev(),
> then cancels a timeout work. unregister_netdev() shuts down a device
> interface and removes it from the kernel tables. If the timeout occurs
> in parallel, the timeout work (pxa168_eth_tx_timeout_task) performs stop
> and open of the device. It may lead to an inconsistent state and memory
> leaks.
> 
> [...]

Here is the summary with links:
  - net: pxa168_eth: Fix a potential data race in pxa168_eth_remove
    https://git.kernel.org/netdev/net/c/0571a753cb07

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-10 23:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-10  8:10 [PATCH] net: pxa168_eth: Fix a potential data race in pxa168_eth_remove Pavel Andrianov
2021-03-10 23:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).