From patchwork Mon Mar 13 10:36:46 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: 13172184 X-Patchwork-Delegate: kuba@kernel.org 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 88E5CC6FD19 for ; Mon, 13 Mar 2023 10:37:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230045AbjCMKhV (ORCPT ); Mon, 13 Mar 2023 06:37:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230055AbjCMKhK (ORCPT ); Mon, 13 Mar 2023 06:37:10 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D4CE50FB5 for ; Mon, 13 Mar 2023 03:37:09 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pbfY1-0008Sy-Pz; Mon, 13 Mar 2023 11:36:57 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pbfY0-003pKc-Tj; Mon, 13 Mar 2023 11:36:56 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pbfY0-004W3a-3U; Mon, 13 Mar 2023 11:36:56 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Shenwei Wang , Clark Wang , NXP Linux Team , netdev@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH net-next 2/9] net: fec: Don't return early on error in .remove() Date: Mon, 13 Mar 2023 11:36:46 +0100 Message-Id: <20230313103653.2753139-3-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230313103653.2753139-1-u.kleine-koenig@pengutronix.de> References: <20230313103653.2753139-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1289; i=u.kleine-koenig@pengutronix.de; h=from:subject; bh=6NeNoe10qCNS1oAAJ3wmxYdcXTYONYnrWH4YyJXGi6g=; b=owEBbQGS/pANAwAKAcH8FHityuwJAcsmYgBkDvyoTD3uvYT54qcEfGm2M/XGRdVZXIaLGinLf KylAfHxIpqJATMEAAEKAB0WIQR+cioWkBis/z50pAvB/BR4rcrsCQUCZA78qAAKCRDB/BR4rcrs CQ28B/45w0wRq6mq3QLY8fWPee6e8EMIJCTrdHriT1imSi0mBEpGePp+/TpQGF+ffhIYfVXj/dV e7OnUPSSO4Dc10bQdtHYjb5oNyNR7wQxWviXxDfKHg8ktqbCqRHMQqpaz/9M0bwJURwczvQkTLR jFnJd98K7KVVuREYe07wrK1bukKwrGfN3+XrEQbwNjoAD8wQ1pURQ/2DRrP9OvBUMvxemYam+US MnF4OhRZQcU+sRwOeALpN7Ek8yv10dqVS99YIGjo63Dsh6Ljs5sX9uPjBK8bZSi3mRpcaekkBkZ /rtoTR7bdONLkiRYGH/pI2PeHV3DhpDtE797+OmyTj4nEkfc 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.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org If waking up the device in .remove() fails, exiting early results in strange state: The platform device will be unbound but not all resources are freed. E.g. the network device continues to exist without an parent. Instead of an early error return, only skip the cleanup that was already done by suspend and release the remaining resources. Signed-off-by: Uwe Kleine-König --- drivers/net/ethernet/freescale/fec_main.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index c73e25f8995e..31d1dc5e9196 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -4465,15 +4465,13 @@ fec_drv_remove(struct platform_device *pdev) struct device_node *np = pdev->dev.of_node; int ret; - ret = pm_runtime_resume_and_get(&pdev->dev); - if (ret < 0) - return ret; + ret = pm_runtime_get_sync(&pdev->dev); cancel_work_sync(&fep->tx_timeout_work); fec_ptp_stop(pdev); unregister_netdev(ndev); fec_enet_mii_remove(fep); - if (fep->reg_phy) + if (ret >= 0 && fep->reg_phy) regulator_disable(fep->reg_phy); if (of_phy_is_fixed_link(np))