Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 934F0C61DA4 for ; Thu, 9 Mar 2023 06:27:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229843AbjCIG1j (ORCPT ); Thu, 9 Mar 2023 01:27:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229830AbjCIG1c (ORCPT ); Thu, 9 Mar 2023 01:27:32 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 820711C5B1; Wed, 8 Mar 2023 22:27:23 -0800 (PST) Received: from dggpemm500005.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4PXK2f0By3zrSZG; Thu, 9 Mar 2023 14:26:34 +0800 (CST) Received: from [10.69.30.204] (10.69.30.204) by dggpemm500005.china.huawei.com (7.185.36.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 9 Mar 2023 14:27:21 +0800 Subject: Re: [PATCH] net: calxeda: fix race condition in xgmac_remove due to unfinshed work From: Yunsheng Lin To: Zheng Wang , , , , , CC: , , <1395428693sheep@gmail.com>, References: <20230309035641.3439953-1-zyytlz.wz@163.com> Message-ID: Date: Thu, 9 Mar 2023 14:27:20 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.69.30.204] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500005.china.huawei.com (7.185.36.74) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/3/9 14:23, Yunsheng Lin wrote: > 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 typo error: unfinshed -> unfinished > >>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 >> --- >> 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); >> > . >