From patchwork Wed Mar 14 21:09:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 10283611 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A365B602BD for ; Wed, 14 Mar 2018 21:10:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80E2628647 for ; Wed, 14 Mar 2018 21:10:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 28C4E28777; Wed, 14 Mar 2018 21:10:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E5ACD286C4 for ; Wed, 14 Mar 2018 21:10:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=vO0hlDPLHtcpEdTmAdqLmsR8Wn65c2/qYdOWBYP44Fk=; b=DZr 4/UmK8X9H4gVeqgzub28twXtXpGAGDJbU1mWyc8pVgCerFgfWA4A0bHgfedD0Z5u9RTYAkaTLRz81 CnPPW9FNzOa2t5dthezSjbTwty97b7uNspG2g0S1G0BjhbqbICrzEIXmHxPJizukKmsuB0kSwMpHI h3u7BaRuaE8kjBgElgQya5xASQj2Lrl1FCI/dPExi8RP4/Moy98bHvcWylnWOJrDUYCgyaoXr7UDW bfGT+OEox1YuJNazRR/O/7YJR3+PFSh9+ONSpL08Yzdg8vbrHBMXo4Z5rhLGosv3uOizDLc0y9y5a mnojTZdQRb5EuMWQI1hm1QH75tzxxbA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ewDey-0006sG-0t; Wed, 14 Mar 2018 21:10:08 +0000 Received: from smtp01.smtpout.orange.fr ([80.12.242.123] helo=smtp.smtpout.orange.fr) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ewDes-0006Uj-Ei for linux-arm-kernel@lists.infradead.org; Wed, 14 Mar 2018 21:10:04 +0000 Received: from linux.numericable.fr ([77.198.79.136]) by mwinf5d01 with ME id Mx9c1x0062wTeBR03x9chl; Wed, 14 Mar 2018 22:09:44 +0100 X-ME-Helo: linux.numericable.fr X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Wed, 14 Mar 2018 22:09:44 +0100 X-ME-IP: 77.198.79.136 From: Christophe JAILLET To: heiko@sntech.de, branislav@radocaj.org, davem@davemloft.net Subject: [PATCH] net: ethernet: arc: Fix a potential memory leak if an optional regulator is deferred Date: Wed, 14 Mar 2018 22:09:34 +0100 Message-Id: <7fd57a4e7f7a41dccf55430cbc43de3b0a7f7826.1521061530.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.14.1 X-Antivirus: Avast (VPS 180314-2, 14/03/2018), Outbound message X-Antivirus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180314_141002_852487_212BB80D X-CRM114-Status: GOOD ( 21.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, Christophe JAILLET , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If the optional regulator is deferrred, we must release some resources. They will be re-allocated when the probe function will be called again. Fixes: 6eacf31139bf ("ethernet: arc: Add support for Rockchip SoC layer device tree bindings") Signed-off-by: Christophe JAILLET --- drivers/net/ethernet/arc/emac_rockchip.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/arc/emac_rockchip.c b/drivers/net/ethernet/arc/emac_rockchip.c index 16f9bee992fe..8ee9dfd0e363 100644 --- a/drivers/net/ethernet/arc/emac_rockchip.c +++ b/drivers/net/ethernet/arc/emac_rockchip.c @@ -169,8 +169,10 @@ static int emac_rockchip_probe(struct platform_device *pdev) /* Optional regulator for PHY */ priv->regulator = devm_regulator_get_optional(dev, "phy"); if (IS_ERR(priv->regulator)) { - if (PTR_ERR(priv->regulator) == -EPROBE_DEFER) - return -EPROBE_DEFER; + if (PTR_ERR(priv->regulator) == -EPROBE_DEFER) { + ret = -EPROBE_DEFER; + goto out_clk_disable; + } dev_err(dev, "no regulator found\n"); priv->regulator = NULL; }