From patchwork Sun Mar 18 22:59:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 10291427 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 C2890602BD for ; Sun, 18 Mar 2018 23:00:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0EF828FC1 for ; Sun, 18 Mar 2018 23:00:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE4CB28FB2; Sun, 18 Mar 2018 23:00:29 +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 1B58628FC1 for ; Sun, 18 Mar 2018 23:00:28 +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=8Tby6ZQN+bMnMtvUnNZIt79rN4Ip1SEp0Y/hc9aO9j0=; b=rLs nwodN25G/n4CRoMf4nu+SMefDJXo588kH2e51AY+JuxDb0iUk9AveYh43zlv8Kzu7KsVIbCORG/Pt OYoBPPo/qcnsWhtfAH3skM8kJOxBq97T4iaPh+0h2njiCrJlwuKSN7SD5g3iehFMm9No5qyHzebva uTnb9pdspokAcrY2sBK1R/Goqh1A4rRBZb/e4HYnjNsg1SBb5bHzfmU+z4MCUTcS2xur8c6dfuisP 1JaNmrWGAVSxTc8b8JWqzQVXv0wbvmAUhxY9mzRkfpJCV/wsL5cMvpusI9Xjg8v9WY5SfAt5POT/0 72zlyOIFvGs5xy+iuNh9L9PaH2KD6kA==; 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 1exhHr-0006Dt-VJ; Sun, 18 Mar 2018 23:00:23 +0000 Received: from smtp05.smtpout.orange.fr ([80.12.242.127] helo=smtp.smtpout.orange.fr) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1exhHR-0005lh-Vp for linux-rockchip@lists.infradead.org; Sun, 18 Mar 2018 23:00:00 +0000 Received: from linux.numericable.fr ([77.198.79.136]) by mwinf5d09 with ME id Pazh1x00G2wTeBR03aziqA; Sun, 18 Mar 2018 23:59:45 +0100 X-ME-Helo: linux.numericable.fr X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 18 Mar 2018 23:59:45 +0100 X-ME-IP: 77.198.79.136 From: Christophe JAILLET To: heiko@sntech.de, branislav@radocaj.org, davem@davemloft.net Subject: [PATCH v2] net: ethernet: arc: Fix a potential memory leak if an optional regulator is deferred Date: Sun, 18 Mar 2018 23:59:36 +0100 Message-Id: <7fd57a4e79da41dccf55430cbc43de340a7f1826.1521061530.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.14.1 X-Antivirus: Avast (VPS 180318-0, 18/03/2018), Outbound message X-Antivirus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180318_155958_340612_797D7408 X-CRM114-Status: GOOD ( 19.28 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms 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-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If the optional regulator is deferred, 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 --- v2: v1 did not compile because of an erroneous variable name. s/ret/err/ --- 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) { + err = -EPROBE_DEFER; + goto out_clk_disable; + } dev_err(dev, "no regulator found\n"); priv->regulator = NULL; }