From patchwork Fri Nov 17 09:16:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 13458559 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=none Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00503D4F for ; Fri, 17 Nov 2023 01:17:18 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r3uyQ-0007gO-38; Fri, 17 Nov 2023 10:17:14 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r3uyP-009e67-5d; Fri, 17 Nov 2023 10:17:13 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1r3uyO-002yJX-Sq; Fri, 17 Nov 2023 10:17:12 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Cc: Siddharth Vadapalli , Roger Quadros , Dan Carpenter , netdev@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH 1/7] net: ethernet: ti: am65-cpsw: Don't error out in .remove() Date: Fri, 17 Nov 2023 10:16:57 +0100 Message-ID: <20231117091655.872426-2-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.42.0.586.gbc5204569f7d.dirty In-Reply-To: <20231117091655.872426-1-u.kleine-koenig@pengutronix.de> References: <20231117091655.872426-1-u.kleine-koenig@pengutronix.de> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1738; i=u.kleine-koenig@pengutronix.de; h=from:subject; bh=Zmf+Sb7WCxuxFHZh9EDWZprTFu2LgP66cPulGLElfjs=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlVy+IjCRiJNFg1lDyufwPqFMmzb9v5ubw+sGP+ dRadg3EAjOJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZVcviAAKCRCPgPtYfRL+ TtW6B/wOrS7SfTwjWIkqEN8WylEaOq5wUblGn5J7QYRFgWtgLoKmmZ/3DQCyuyChPUPPnCMapKd czRZ1nw8qZXqEXTqtkA6JphtgrjpnfkiXST47Zw4JviZtxe3q5Oey6sZ3pL4GLxKjAVKek1VSzK WFaN25FEJjrKKjBe2RFBOfNzIliuWCYwZyV8pWx6UQZg+B7zgLb8LfOqOoWYx+99jpZPI79kKux 6Fw4t9wPGIQFXuPUI4yrHfL2BfwhMsoiRIjVzxOKoL8qu6TlQEnDJDH1Xz1GyWhqM7PUyk2GNli 2OpiJ5oy23TZl9LSmAysF2LqNuchvyrMFuQ7DeCct00QTB7y X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Returning early from .remove() with an error code still results in the driver unbinding the device. So the driver core ignores the returned error code and the resources that were not freed are never catched up. In combination with devm this also often results in use-after-free bugs. In case of the am65-cpsw-nuss driver there is an error path, but it's never taken because am65_cpts_resume() never fails (which however might be another problem). Still make this explicit and drop the early return in exchange for an error message (that is more useful than the error the driver core emits when .remove() returns non-zero). This prepares changing am65_cpsw_nuss_remove() to return void. Fixes: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver") Signed-off-by: Uwe Kleine-König --- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c index ece9f8df98ae..960cb3fa0754 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -3007,9 +3007,12 @@ static int am65_cpsw_nuss_remove(struct platform_device *pdev) common = dev_get_drvdata(dev); - ret = pm_runtime_resume_and_get(&pdev->dev); + ret = pm_runtime_get_sync(&pdev->dev); if (ret < 0) - return ret; + /* am65_cpts_resume() doesn't fail, so handling ret < 0 is only + * for the sake of completeness. + */ + dev_err(dev, "runtime resume failed (%pe)\n", ERR_PTR(ret)); am65_cpsw_unregister_devlink(common); am65_cpsw_unregister_notifiers(common); From patchwork Fri Nov 17 09:16:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 13458568 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=none Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4969D51 for ; Fri, 17 Nov 2023 01:17:27 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r3uyP-0007gP-QB; Fri, 17 Nov 2023 10:17:13 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r3uyP-009e6A-CX; Fri, 17 Nov 2023 10:17:13 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1r3uyP-002yJb-3L; Fri, 17 Nov 2023 10:17:13 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Cc: Siddharth Vadapalli , Ravi Gunasekaran , Roger Quadros , Simon Horman , Yunsheng Lin , Stanislav Fomichev , Marek Majtyka , Rob Herring , Mugunthan V N , linux-omap@vger.kernel.org, netdev@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH 2/7] net: ethernet: ti: cpsw: Don't error out in .remove() Date: Fri, 17 Nov 2023 10:16:58 +0100 Message-ID: <20231117091655.872426-3-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.42.0.586.gbc5204569f7d.dirty In-Reply-To: <20231117091655.872426-1-u.kleine-koenig@pengutronix.de> References: <20231117091655.872426-1-u.kleine-koenig@pengutronix.de> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1891; i=u.kleine-koenig@pengutronix.de; h=from:subject; bh=mRlxVGBjOW+sHBqJcFFxN2V+8op/8Ztc44BTgG2kkTc=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlVy+JX7JX54FLhK+Ph4PRFjYhrozP75HV5r1Hh eI54zRdHrCJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZVcviQAKCRCPgPtYfRL+ TukvCAClEeHXl2S3JJqY2Bxwz4qdVHZrIaNBphbJm/tByatOnJypsqbGilBmtS8u4DOJ+9JdsST /40Lod7dQZ432LRW1PomY92egZ5iSekSFW+KE12uA1lhufDdNlc/fZNoHbnaa7t3v6cpV2n1OUc T1Qe5rWHW1XM5Ak6pT7CsxFKqZKX8mZykXfcqriVvKO8hgJjTLkybTWZQwMccbuPDy5oNYxK0Da ipSgmSTQ225CTGdMswUGhsAZjspi9R0T22vUikLBqY/vyxx6+fzrc+wV6xBfGYEETdRVNWJMQJo jgwiZUGJGJl6mMSy4Sh8UJAcq7Z04ffRmlWOK5XeEGrrK5ex X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Returning early from .remove() with an error code still results in the driver unbinding the device. So the driver core ignores the returned error code and the resources that were not freed are never catched up. In combination with devm this also often results in use-after-free bugs. If runtime resume fails, it's still important to free all resources, so don't return with an error code, but emit an error message and continue freeing acquired stuff. This prepares changing cpsw_remove() to return void. Fixes: 8a0b6dc958fd ("drivers: net: cpsw: fix wrong regs access in cpsw_remove") Signed-off-by: Uwe Kleine-König --- drivers/net/ethernet/ti/cpsw.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index ca4d4548f85e..db5a2ba8a6d4 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -1727,16 +1727,24 @@ static int cpsw_remove(struct platform_device *pdev) struct cpsw_common *cpsw = platform_get_drvdata(pdev); int i, ret; - ret = pm_runtime_resume_and_get(&pdev->dev); + ret = pm_runtime_get_sync(&pdev->dev); if (ret < 0) - return ret; + /* There is no need to do something about that. The important + * thing is to not exit early, but do all cleanup that doesn't + * require register access. + */ + dev_err(&pdev->dev, "runtime resume failed (%pe)\n", + ERR_PTR(ret)); for (i = 0; i < cpsw->data.slaves; i++) if (cpsw->slaves[i].ndev) unregister_netdev(cpsw->slaves[i].ndev); - cpts_release(cpsw->cpts); - cpdma_ctlr_destroy(cpsw->dma); + if (ret >= 0) { + cpts_release(cpsw->cpts); + cpdma_ctlr_destroy(cpsw->dma); + } + cpsw_remove_dt(pdev); pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); From patchwork Fri Nov 17 09:16:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 13458567 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=none Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD1BFD4E for ; Fri, 17 Nov 2023 01:17:27 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r3uyQ-0007gT-3E; Fri, 17 Nov 2023 10:17:14 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r3uyP-009e6D-Je; Fri, 17 Nov 2023 10:17:13 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1r3uyP-002yJf-AC; Fri, 17 Nov 2023 10:17:13 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Cc: Siddharth Vadapalli , Ravi Gunasekaran , Roger Quadros , Alexei Starovoitov , Marek Majtyka , Gerhard Engleder , Rob Herring , Yunsheng Lin , Ilias Apalodimas , linux-omap@vger.kernel.org, netdev@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH 3/7] net: ethernet: ti: cpsw-new: Don't error out in .remove() Date: Fri, 17 Nov 2023 10:16:59 +0100 Message-ID: <20231117091655.872426-4-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.42.0.586.gbc5204569f7d.dirty In-Reply-To: <20231117091655.872426-1-u.kleine-koenig@pengutronix.de> References: <20231117091655.872426-1-u.kleine-koenig@pengutronix.de> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1910; i=u.kleine-koenig@pengutronix.de; h=from:subject; bh=pRqqeKcdhQwzz3WqDYFX15m8Wmx7j6+SSxzjpB2PRHA=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlVy+L5i60+g5zCFQoR9XpwdVxPzWS+SXuTSSRr /z0vzxzteGJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZVcviwAKCRCPgPtYfRL+ TupxB/44enSu4ws7zGlfVg6j+hGHF9PYcDHYkCgI3BqHLGROmcy13aQSxslOviwXJLo0y4t1b7G MlzxL95ycnY4mlQptJiZ1+ahqS1/iO4aoZw1d2OiLFly8dUWiw6FcIM435EWjKCoDjUjx5oam7e cCFty+Zc7wxIM1con2yuwanbB0+lB3GoqIF7TwUEn5k3lRxcrclmc6ECPBd5Eio4GBtW7x1w5d+ hVIs7knzwXHyRDDdD6frYUYncPr3nZSSb6p2LhNTQXQuRSmMxwbDV9scRwdsJ9GB0nfIRjc+Svb PF3kQDLWMoItthCIMaer1+UUwaZ8+V+2mNMnvIrBRZ0kusXm X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Returning early from .remove() with an error code still results in the driver unbinding the device. So the driver core ignores the returned error code and the resources that were not freed are never catched up. In combination with devm this also often results in use-after-free bugs. If runtime resume fails, it's still important to free all resources, so don't return with an error code, but emit an error message and continue freeing acquired stuff. This prepares changing cpsw_remove() to return void. Fixes: ed3525eda4c4 ("net: ethernet: ti: introduce cpsw switchdev based driver part 1 - dual-emac") Signed-off-by: Uwe Kleine-König Acked-by: Ilias Apalodimas --- drivers/net/ethernet/ti/cpsw_new.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/ti/cpsw_new.c b/drivers/net/ethernet/ti/cpsw_new.c index 0e4f526b1753..a6ce409f563c 100644 --- a/drivers/net/ethernet/ti/cpsw_new.c +++ b/drivers/net/ethernet/ti/cpsw_new.c @@ -2042,16 +2042,24 @@ static int cpsw_remove(struct platform_device *pdev) struct cpsw_common *cpsw = platform_get_drvdata(pdev); int ret; - ret = pm_runtime_resume_and_get(&pdev->dev); + ret = pm_runtime_get_sync(&pdev->dev); if (ret < 0) - return ret; + /* There is no need to do something about that. The important + * thing is to not exit early, but do all cleanup that doesn't + * requrie register access. + */ + dev_err(&pdev->dev, "runtime resume failed (%pe)\n", + ERR_PTR(ret)); cpsw_unregister_notifiers(cpsw); cpsw_unregister_devlink(cpsw); cpsw_unregister_ports(cpsw); - cpts_release(cpsw->cpts); - cpdma_ctlr_destroy(cpsw->dma); + if (ret >= 0) { + cpts_release(cpsw->cpts); + cpdma_ctlr_destroy(cpsw->dma); + } + cpsw_remove_dt(cpsw); pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); From patchwork Fri Nov 17 09:17:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 13458558 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=none Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC453D4E for ; Fri, 17 Nov 2023 01:17:18 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r3uyQ-0007ga-5t; Fri, 17 Nov 2023 10:17:14 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r3uyP-009e6G-P4; Fri, 17 Nov 2023 10:17:13 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1r3uyP-002yJj-Fq; Fri, 17 Nov 2023 10:17:13 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Cc: Siddharth Vadapalli , Roger Quadros , Dan Carpenter , netdev@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH 4/7] net: ethernet: ti: am65-cpsw: Convert to platform remove callback returning void Date: Fri, 17 Nov 2023 10:17:00 +0100 Message-ID: <20231117091655.872426-5-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.42.0.586.gbc5204569f7d.dirty In-Reply-To: <20231117091655.872426-1-u.kleine-koenig@pengutronix.de> References: <20231117091655.872426-1-u.kleine-koenig@pengutronix.de> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1944; i=u.kleine-koenig@pengutronix.de; h=from:subject; bh=SqKGEkAli7OZINyHIZ5Yhy739OdeoSHIXRil6ZyFrBM=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlVy+MbRgW5BuI+sKBu8C/ycUxeqXm+asu6QTtQ 4sktVi/BCWJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZVcvjAAKCRCPgPtYfRL+ TuZGB/9fUXmdY+HH0t/GNKAi7V3faZlJqkUt78P+Sjox/XxMDVImzJn1HXUAseU5ZFQR30jpEUo oe7rxJPwHpvKlFEjT+dWZDZT+GaR9op2Zg4MLN0rVzGEtcGiIr8T7hgxMFniEn7276flHo5YmCr g08TJaDG4n8huDCqk/3VCk5LDUqmcxHTMoWDm+wMsl11t46v0aOzAmhY9i1vawTQksAe4Az+7+Q EmYDfRUiq3IKpJ2B2Hj3wuBVtOQj34q4YV4Uf38CuXzod4g4vyNujrjKHihAsYY7HvXLB6wKYS8 Em3zQ6JB5d06U7CBvm9lta6AZ98JZ8idY5/jKJh7RxupWzxy X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new(), which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove(). Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König Reviewed-by: Roger Quadros --- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c index 960cb3fa0754..83730b566dff 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -2999,7 +2999,7 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev) return ret; } -static int am65_cpsw_nuss_remove(struct platform_device *pdev) +static void am65_cpsw_nuss_remove(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct am65_cpsw_common *common; @@ -3030,7 +3030,6 @@ static int am65_cpsw_nuss_remove(struct platform_device *pdev) pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); - return 0; } static int am65_cpsw_nuss_suspend(struct device *dev) @@ -3130,7 +3129,7 @@ static struct platform_driver am65_cpsw_nuss_driver = { .pm = &am65_cpsw_nuss_dev_pm_ops, }, .probe = am65_cpsw_nuss_probe, - .remove = am65_cpsw_nuss_remove, + .remove_new = am65_cpsw_nuss_remove, }; module_platform_driver(am65_cpsw_nuss_driver); From patchwork Fri Nov 17 09:17:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 13458569 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=none Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14E58D4D for ; Fri, 17 Nov 2023 01:17:29 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r3uyQ-0007go-Cg; Fri, 17 Nov 2023 10:17:14 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r3uyP-009e6K-VG; Fri, 17 Nov 2023 10:17:13 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1r3uyP-002yJm-Lp; Fri, 17 Nov 2023 10:17:13 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Cc: Siddharth Vadapalli , Ravi Gunasekaran , Roger Quadros , Kumar Kartikeya Dwivedi , Stanislav Fomichev , Jesse Brandeburg , Rob Herring , Marek Majtyka , Yunsheng Lin , linux-omap@vger.kernel.org, netdev@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH 5/7] net: ethernet: ti: cpsw: Convert to platform remove callback returning void Date: Fri, 17 Nov 2023 10:17:01 +0100 Message-ID: <20231117091655.872426-6-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.42.0.586.gbc5204569f7d.dirty In-Reply-To: <20231117091655.872426-1-u.kleine-koenig@pengutronix.de> References: <20231117091655.872426-1-u.kleine-koenig@pengutronix.de> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1796; i=u.kleine-koenig@pengutronix.de; h=from:subject; bh=AFKDccbj7KVdxjjm+VYAVvkLNk+QVUxW4yHwNz8tuIk=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlVy+NZdmjkLIHdK9BlhoRLimmKKlCp9u4QgTvO U4IA9g8McKJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZVcvjQAKCRCPgPtYfRL+ TmzTCACjfDNtDbr7jWf/bK3FdYpzjXe3NGiGaYQkDmMiHeJklBWV5YfyXhySfGfDwfn6/kByk1L FsQTyBkgjhWqg3litFcmmp2v4bZ6zhuHKBPK1d91jIDRynghs1FLRjb0VZVO9niobQ4IRnJiIe8 797ndA1BXRrIXtUSXbnvXL0xDCqTh53aonpd+xEunoRcZrH2cDCTh3R3Kpj/yUGxq9rcWU9/n0O 1TieUdd3ytdNoXiGdx+VBfJb8ufNNnU8rCyRvq2LJaD9k8aG3jE2r4+bnowNfi5A5mz5xAvf6mE RHBAwkv+zKVE2+scpU+923PrB7RPKSgVg+nI8tQZ4/iv8xhb X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new(), which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove(). Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König Reviewed-by: Roger Quadros --- drivers/net/ethernet/ti/cpsw.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index db5a2ba8a6d4..ed29a76420f8 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -1722,7 +1722,7 @@ static int cpsw_probe(struct platform_device *pdev) return ret; } -static int cpsw_remove(struct platform_device *pdev) +static void cpsw_remove(struct platform_device *pdev) { struct cpsw_common *cpsw = platform_get_drvdata(pdev); int i, ret; @@ -1748,7 +1748,6 @@ static int cpsw_remove(struct platform_device *pdev) cpsw_remove_dt(pdev); pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); - return 0; } #ifdef CONFIG_PM_SLEEP @@ -1803,7 +1802,7 @@ static struct platform_driver cpsw_driver = { .of_match_table = cpsw_of_mtable, }, .probe = cpsw_probe, - .remove = cpsw_remove, + .remove_new = cpsw_remove, }; module_platform_driver(cpsw_driver); From patchwork Fri Nov 17 09:17:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 13458570 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=none Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 909B2D4F for ; Fri, 17 Nov 2023 01:17:29 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r3uyQ-0007h4-QU; Fri, 17 Nov 2023 10:17:14 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r3uyQ-009e6N-5q; Fri, 17 Nov 2023 10:17:14 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1r3uyP-002yJr-Sc; Fri, 17 Nov 2023 10:17:13 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Cc: Siddharth Vadapalli , Ravi Gunasekaran , Roger Quadros , Alexander Duyck , Jesse Brandeburg , Yunsheng Lin , Marek Majtyka , Rob Herring , linux-omap@vger.kernel.org, netdev@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH 6/7] net: ethernet: ti: cpsw-new: Convert to platform remove callback returning void Date: Fri, 17 Nov 2023 10:17:02 +0100 Message-ID: <20231117091655.872426-7-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.42.0.586.gbc5204569f7d.dirty In-Reply-To: <20231117091655.872426-1-u.kleine-koenig@pengutronix.de> References: <20231117091655.872426-1-u.kleine-koenig@pengutronix.de> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1849; i=u.kleine-koenig@pengutronix.de; h=from:subject; bh=okHKw25VgeWUFYd2avv49A8Ij4U9Ek22DOHwr9QInRk=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlVy+O5ufeBrybGQ4s7etDKUNLrzfUTroyU7BIJ Q4jDiTBQjmJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZVcvjgAKCRCPgPtYfRL+ TioUB/9Eq9iqGQQqxO6fiyfaAtVw3VnJaTfd8xxeA1755kDQYDpapiyDmxLZ7tXAoaN+/bhG70V hSHv5bbmTMhLHi4zsn/tv+OCjEQ8ZkrIhvCTMqOh3i6gQIjztb96NDuIKNFzL76OXr2yR+Rhbj7 3eCKKP9//kXnNod+6Pno1ZFwS/e2bzHBkHnZcZDQvxajTCbgBWwu6ZWGrISxu+h4+pXk/DO8/qM 2fiBCoQNxQPBgAY5bWygbAOay5YzzyvKPoGB+r5aYQNkey8mcF6S6GpEaBdB6iSV/ctJ0LlKB9L bM8EeF0L3xTLJh6efd6Bpksx7rSp8LBIODlG7tk91GvqZuNf X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new(), which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove(). Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König Reviewed-by: Roger Quadros --- drivers/net/ethernet/ti/cpsw_new.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/ti/cpsw_new.c b/drivers/net/ethernet/ti/cpsw_new.c index a6ce409f563c..dae8d0203021 100644 --- a/drivers/net/ethernet/ti/cpsw_new.c +++ b/drivers/net/ethernet/ti/cpsw_new.c @@ -2037,7 +2037,7 @@ static int cpsw_probe(struct platform_device *pdev) return ret; } -static int cpsw_remove(struct platform_device *pdev) +static void cpsw_remove(struct platform_device *pdev) { struct cpsw_common *cpsw = platform_get_drvdata(pdev); int ret; @@ -2063,7 +2063,6 @@ static int cpsw_remove(struct platform_device *pdev) cpsw_remove_dt(cpsw); pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); - return 0; } static int __maybe_unused cpsw_suspend(struct device *dev) @@ -2124,7 +2123,7 @@ static struct platform_driver cpsw_driver = { .of_match_table = cpsw_of_mtable, }, .probe = cpsw_probe, - .remove = cpsw_remove, + .remove_new = cpsw_remove, }; module_platform_driver(cpsw_driver); From patchwork Fri Nov 17 09:17:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 13458557 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=none Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26CF6D4D for ; Fri, 17 Nov 2023 01:17:17 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r3uyQ-0007hH-Q2; Fri, 17 Nov 2023 10:17:14 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r3uyQ-009e6T-CI; Fri, 17 Nov 2023 10:17:14 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1r3uyQ-002yJv-3G; Fri, 17 Nov 2023 10:17:14 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Cc: Christian Marangi , Alex Elder , Rob Herring , netdev@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH 7/7] net: ethernet: ezchip: Convert to platform remove callback returning void Date: Fri, 17 Nov 2023 10:17:03 +0100 Message-ID: <20231117091655.872426-8-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.42.0.586.gbc5204569f7d.dirty In-Reply-To: <20231117091655.872426-1-u.kleine-koenig@pengutronix.de> References: <20231117091655.872426-1-u.kleine-koenig@pengutronix.de> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1952; i=u.kleine-koenig@pengutronix.de; h=from:subject; bh=WCsH3AMo/doRPWS4MbdyGRufJOyZqp9N04kNPeC/Gik=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlVy+PV6v2I6EmNxRvcipcDEJ99dfcKTYnDgtlb 3D2ierZF62JATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZVcvjwAKCRCPgPtYfRL+ Tn27B/wN7nxid4K7vbgw/2MDnGz8u/TrBtAQubQ/5pTOGLEB9cWB+TYr70GEGt06sqxx2TLcZNW DxsSjahBCYUb6t/N1Nfqa8RzEGJuIfuxMERnPe1HWJyGpwfJ2mL0ie97hXIsx2m/h6SxBsaWqAW HuGWKgqg6XM8kHBGzvIJ/cadUgkLd4RYBuLzc63BQ11mCS2AKAEYbpDNuQOcl89pA5FrL1b5a1R 3c/oEt6A+JZAfy4vtS19+r1paaOtiwRe3dCp1zTF2Ygx2VrHntzBH68Hi9YP8qUEEJa8mLuuR02 ce/Is+SbUBE/NQfJeMvcb65s4hoLt6ZE0nKRUwCTzLeItYwI X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new(), which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove(). Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König --- drivers/net/ethernet/ezchip/nps_enet.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/ezchip/nps_enet.c b/drivers/net/ethernet/ezchip/nps_enet.c index 4d7184d46824..07c2b701b5fa 100644 --- a/drivers/net/ethernet/ezchip/nps_enet.c +++ b/drivers/net/ethernet/ezchip/nps_enet.c @@ -633,7 +633,7 @@ static s32 nps_enet_probe(struct platform_device *pdev) return err; } -static s32 nps_enet_remove(struct platform_device *pdev) +static void nps_enet_remove(struct platform_device *pdev) { struct net_device *ndev = platform_get_drvdata(pdev); struct nps_enet_priv *priv = netdev_priv(ndev); @@ -641,8 +641,6 @@ static s32 nps_enet_remove(struct platform_device *pdev) unregister_netdev(ndev); netif_napi_del(&priv->napi); free_netdev(ndev); - - return 0; } static const struct of_device_id nps_enet_dt_ids[] = { @@ -653,7 +651,7 @@ MODULE_DEVICE_TABLE(of, nps_enet_dt_ids); static struct platform_driver nps_enet_driver = { .probe = nps_enet_probe, - .remove = nps_enet_remove, + .remove_new = nps_enet_remove, .driver = { .name = DRV_NAME, .of_match_table = nps_enet_dt_ids,