mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yunsheng Lin <linyunsheng@huawei.com>
To: Zheng Wang <zyytlz.wz@163.com>, <davem@davemloft.net>,
	<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
	<netdev@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <hackerzheng666@gmail.com>,
	<1395428693sheep@gmail.com>, <alex000young@gmail.com>
Subject: Re: [PATCH] net: calxeda: fix race condition in xgmac_remove due to unfinshed work
Date: Thu, 9 Mar 2023 14:23:51 +0800	[thread overview]
Message-ID: <ec579c96-9955-f317-b37a-4f3fcd0c206e@huawei.com> (raw)
In-Reply-To: <20230309035641.3439953-1-zyytlz.wz@163.com>

On 2023/3/9 11:56, Zheng Wang wrote:
> In xgmac_probe, the priv->tx_timeout_work is bound with 
> xgmac_tx_timeout_work. In xgmac_remove, if there is an 
> unfinished work, there might be a race condition that 
> priv->base was written byte after iounmap it.
> 
> Fix it by finishing the work before cleanup.

This should go to net branch, so title should be:

 [PATCH net] net: calxeda: fix race condition in xgmac_remove due to unfinshed work

From history commit, it seems more common to use "net: calxedaxgmac" instead of
"net: calxeda", I am not sure which one is better.

Also there should be a Fixes tag for net branch, maybe:

Fixes: 8746f671ef04 ("net: calxedaxgmac: fix race between xgmac_tx_complete and xgmac_tx_err")


> 
> Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
> ---
>  drivers/net/ethernet/calxeda/xgmac.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ethernet/calxeda/xgmac.c b/drivers/net/ethernet/calxeda/xgmac.c
> index f4f87dfa9687..94c3804001e3 100644
> --- a/drivers/net/ethernet/calxeda/xgmac.c
> +++ b/drivers/net/ethernet/calxeda/xgmac.c
> @@ -1831,6 +1831,7 @@ static int xgmac_remove(struct platform_device *pdev)
>  	/* Free the IRQ lines */
>  	free_irq(ndev->irq, ndev);
>  	free_irq(priv->pmt_irq, ndev);
> +	cancel_work_sync(&priv->tx_timeout_work);

It seems the blow function need to stop the dev_watchdog() from
calling dev->netdev_ops->ndo_tx_timeout before calling
cancel_work_sync(&priv->tx_timeout_work), otherwise the
dev_watchdog() may trigger the priv->tx_timeout_work to run again.

	netif_carrier_off(ndev);
	netif_tx_disable(ndev);

>  
>  	unregister_netdev(ndev);
>  	netif_napi_del(&priv->napi);
> 

  reply	other threads:[~2023-03-09  6:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-09  3:56 Zheng Wang
2023-03-09  6:23 ` Yunsheng Lin [this message]
2023-03-09  6:27   ` Yunsheng Lin
2023-03-09  7:26     ` Zheng Hacker
2023-03-09  7:25   ` Zheng Hacker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ec579c96-9955-f317-b37a-4f3fcd0c206e@huawei.com \
    --to=linyunsheng@huawei.com \
    --cc=1395428693sheep@gmail.com \
    --cc=alex000young@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hackerzheng666@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=zyytlz.wz@163.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®