From patchwork Sat Jan 6 08:00:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 10147725 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 A7A0560134 for ; Sat, 6 Jan 2018 08:15:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B90E28581 for ; Sat, 6 Jan 2018 08:15:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7071A28697; Sat, 6 Jan 2018 08:15:46 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 C3AE228581 for ; Sat, 6 Jan 2018 08:15:45 +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=xOn/xbIIR8Lwta7H/bMRc1ivxxLbU/lZ4EMSCoPOAFU=; b=E+X jAZC6kPOWvL4RRjXEa49z8VV8jyZWJwYP46IK1fB54MFd2pTb29omuk5qSjpkzVdjSxJpgpz7MV53 ztdjYrbsMnPYtsVT9CMEV2jvWRIQullUWHpS+XN60ktFuDruB/cHRXQuwzQce7UWmYj6fPbAxVDZ2 1GUNbnR7p3vPTSfawjYJtIsvZNx7Z0EeVYNbAiOaX206Y73NCqYTl0fivWzVKEwWbP9s2ko8BtzQ1 8BeqxdsO1FofUG4Y1HT58ESULywnCBEybd4WCSvmLYhXWUNnFiy2z9br997Y3N4KYxbwkbDez/jsd uZVPPxhIbWCefMAO890EkVSn4Nk0NyQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eXjdn-0003Ov-AO; Sat, 06 Jan 2018 08:15:43 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eXjdl-00032h-12 for linux-arm-kernel@bombadil.infradead.org; Sat, 06 Jan 2018 08:15:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=A20A+FvIOHz4XAJ5AC7t8CNjmCof+slB81rR+SsdM/8=; b=dqRVA7SF1yc05ZoTL/MHNQ2YU JFsxChhSnj0tJ60Wid0LIS+/aloY7Wo3xenm8vmS14h24/6Y5vv7SCdnhOVnodZDkAXly1GnoeYuM 3Y3ly9wR8hlXV0yLI+4Kcj4xOT/4/w7kxBAYmkNzyhbw3NJOQ5n+RvbzuYu5FG49foxQQI+Yko3Rl EudDNsFVMnTT7OlumlV06ScD5Fx/WKVKQxZuo3F107xEFADN5c1xtxxYJmsm6e5WSIZArCdVdVOHO GINotUArEn/KWII8V2gB0+7JesjE5eztKyfqp2ucXW2D3GhQf6vgqjnTaheNGe527idEnWwULMoH5 KEzgK5AKA==; Received: from smtp03.smtpout.orange.fr ([80.12.242.125] helo=smtp.smtpout.orange.fr) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eXjPv-0002Gt-E6 for linux-arm-kernel@lists.infradead.org; Sat, 06 Jan 2018 08:01:25 +0000 Received: from localhost.localdomain ([90.107.118.99]) by mwinf5d38 with ME id uw151w00J28lVBu03w16NL; Sat, 06 Jan 2018 09:01:08 +0100 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 06 Jan 2018 09:01:08 +0100 X-ME-IP: 90.107.118.99 From: Christophe JAILLET To: andrew@lunn.ch, f.fainelli@gmail.com, maxime.ripard@free-electrons.com, wens@csie.org Subject: [PATCH] mdio-sun4i: Fix a memory leak Date: Sat, 6 Jan 2018 09:00:09 +0100 Message-Id: <20180106080009.5325-1-christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.14.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180106_080123_571898_F1BDA483 X-CRM114-Status: GOOD ( 13.12 ) 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, Christophe JAILLET , kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, 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 probing of the regulator is deferred, the memory allocated by 'mdiobus_alloc_size()' will be leaking. It should be freed before the next call to 'sun4i_mdio_probe()' which will reallocate it. Fixes: 4bdcb1dd9feb ("net: Add MDIO bus driver for the Allwinner EMAC") Signed-off-by: Christophe JAILLET --- drivers/net/phy/mdio-sun4i.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/mdio-sun4i.c b/drivers/net/phy/mdio-sun4i.c index 135296508a7e..6425ce04d3f9 100644 --- a/drivers/net/phy/mdio-sun4i.c +++ b/drivers/net/phy/mdio-sun4i.c @@ -118,8 +118,10 @@ static int sun4i_mdio_probe(struct platform_device *pdev) data->regulator = devm_regulator_get(&pdev->dev, "phy"); if (IS_ERR(data->regulator)) { - if (PTR_ERR(data->regulator) == -EPROBE_DEFER) - return -EPROBE_DEFER; + if (PTR_ERR(data->regulator) == -EPROBE_DEFER) { + ret = -EPROBE_DEFER; + goto err_out_free_mdiobus; + } dev_info(&pdev->dev, "no regulator found\n"); data->regulator = NULL;