From patchwork Sat Mar 11 18:04:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zheng Wang X-Patchwork-Id: 68164 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp395034wrd; Sat, 11 Mar 2023 10:21:12 -0800 (PST) X-Google-Smtp-Source: AK7set/SIZwcZkvqDjzMvPxgvIJ10GhdvubiGwZst28Rw31Dov4IVKp5M/jFsWPLnbj72yXFbbjP X-Received: by 2002:a17:902:c412:b0:19c:be03:d18b with SMTP id k18-20020a170902c41200b0019cbe03d18bmr40683412plk.22.1678558871832; Sat, 11 Mar 2023 10:21:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678558871; cv=none; d=google.com; s=arc-20160816; b=HsnwfOTQpvsZNT5C74WGQ5ywEPQOlIMYzD3ugR0HX/dSAS7gv+njloIr3nEdgz1XkW bIWjFyPeOWKwubo1mYVFnA6aTv0DrlPFHV7sxBH10hL91cc7Rzqs4749ht8QFCRVX24Z zg+GDqewPzsIab8AeSWhNaCyELCfpNlHlknz7sy2qzUsG3X+7W0WXz76rrW4WfTJWGw+ v490UN+9oUjrMG7JvN9EwK7yleO9UzCBwBFf5lMNDHdjB9rG/PXcEEr3bHlYwA2O36z9 qJHguvFUbWhGmyOGkzVuJT+lfc2jlnmk0o2NLZEyJpZIrMRJITUTozJCG5hcuFvSFx+1 tRbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=C7fD2xpk7NTbx5k6GnhNQoHvfkr24LqkPt+Xv71fq70=; b=dLpyffbFEnQ7EdzeJdrPfl+gGYVtYfxsUzCxvaR+9Qx+HTDbhshli+e1sy8RgyRRfB iHJ0hJmVwTnp1CMVt/X+yviLwAq8vNkcjMUgF5zBscjWUpcAcG0f6rq3vunETCIvvx/v gu50Xqg9h5DswmLg7xLkfU7eaHkCUb14DJsuprmZtrUc4mXYRC/kE8Y47jrLQwUTMRTb 03yt7FJBFlBQ0MQkkZ2ax+InPhb9B24cqUXUQgWQjlckE9b/DW1nH6RV0ERjr/VMSmWF JS87TqEmw27OK2shAC7lukoHaM1IWVy+Dxtw+/zRmJLwUloyQ8jXI8MC5Ra0K8Mtzqqt 7pMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=oqSt28aN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ky14-20020a170902f98e00b0019f239f4966si2101082plb.568.2023.03.11.10.20.59; Sat, 11 Mar 2023 10:21:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=oqSt28aN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230268AbjCKSEj (ORCPT + 99 others); Sat, 11 Mar 2023 13:04:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230095AbjCKSEi (ORCPT ); Sat, 11 Mar 2023 13:04:38 -0500 Received: from m12.mail.163.com (m12.mail.163.com [220.181.12.198]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 812AD50996; Sat, 11 Mar 2023 10:04:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=C7fD2 xpk7NTbx5k6GnhNQoHvfkr24LqkPt+Xv71fq70=; b=oqSt28aNE+4ZKP8FCVlB2 PH9BOTQS6uYCmhqHN1EwNicuJpNzHHIczkP2TLFmdbHS93VXqUtmm4TWW6s+S4UN LXgcuRyw0BHbjPM/78CMuGPWn+IgK6ZrmCLnIaBEcTIFnR69DMA6o+SMOoCgZE9I GWZb7JCFMFM/1rbVQSrl9k= Received: from leanderwang-LC2.localdomain (unknown [111.206.145.21]) by zwqz-smtp-mta-g2-4 (Coremail) with SMTP id _____wAHVO2WwgxkGhAgDA--.10863S2; Sun, 12 Mar 2023 02:04:06 +0800 (CST) From: Zheng Wang To: davem@davemloft.net Cc: edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, mkl@pengutronix.de, j.neuschaefer@gmx.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linyunsheng@huawei.com, hackerzheng666@gmail.com, 1395428693sheep@gmail.com, alex000young@gmail.com, Zheng Wang Subject: [PATCH net v2] net: calxedaxgmac: fix race condition in xgmac_remove due to unfinished work Date: Sun, 12 Mar 2023 02:04:04 +0800 Message-Id: <20230311180404.4007176-1-zyytlz.wz@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CM-TRANSID: _____wAHVO2WwgxkGhAgDA--.10863S2 X-Coremail-Antispam: 1Uf129KBjvdXoW7Jry5Kw1kAF18GF1fCr45Wrg_yoWkKwcEga s293WxGw4UJF1vka1kCr4UZry8t3Wq9w1rXryIgrWa93sxJr1xXrs7uFy7JF45Ww1DGry7 WFnIyrWSyw1jqjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRKPfHUUUUUU== X-Originating-IP: [111.206.145.21] X-CM-SenderInfo: h2113zf2oz6qqrwthudrp/1tbiGhMvU1aEEiTKVgACsP X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_VALIDITY_RPBL,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760096547803365019?= X-GMAIL-MSGID: =?utf-8?q?1760096547803365019?= 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. Fixes: 8746f671ef04 ("net: calxedaxgmac: fix race between xgmac_tx_complete and xgmac_tx_err") Signed-off-by: Zheng Wang --- v2: - fix typo,add Fixes label and stop dev_watchdog so that it will handle no more timeout work suggested by Yunsheng Lin --- drivers/net/ethernet/calxeda/xgmac.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/calxeda/xgmac.c b/drivers/net/ethernet/calxeda/xgmac.c index f4f87dfa9687..f0880538f6f3 100644 --- a/drivers/net/ethernet/calxeda/xgmac.c +++ b/drivers/net/ethernet/calxeda/xgmac.c @@ -1832,6 +1832,10 @@ static int xgmac_remove(struct platform_device *pdev) free_irq(ndev->irq, ndev); free_irq(priv->pmt_irq, ndev); + netif_carrier_off(ndev); + netif_tx_disable(ndev); + cancel_work_sync(&priv->tx_timeout_work); + unregister_netdev(ndev); netif_napi_del(&priv->napi);