Received: by 10.223.185.116 with SMTP id b49csp6393288wrg; Wed, 28 Feb 2018 08:40:45 -0800 (PST) X-Google-Smtp-Source: AH8x227KzGSY+me0jS6ySfaeToD8hxd0JZ2gbiqHJk1JiDnkSJ43MCXFUryQXY4fOCAJQVDygPiJ X-Received: by 2002:a17:902:550f:: with SMTP id f15-v6mr18395058pli.50.1519836045707; Wed, 28 Feb 2018 08:40:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519836045; cv=none; d=google.com; s=arc-20160816; b=BC+qiBDPCY7IevqEABwFgswvYvQHKdqHk6zB78Naz8ysXrC5PcYYxsZpS65gL7l48Z j9M/KrfqVjJSR4+8dOKjNxj3IaxgWYhAklc/AferypkPMgxcfuNdXvoLfUTQbZD0kYd/ 5lnw5apYyCwrPHO9LFH33cSyikiO50u97GP4+kXyuWJx+TPTifgMzR4AmDk25NudV4nA QjxZyH3N67I3CZ686ei2PxjgXWs28Zh8Zk4D8MjfmVkG8GwRVmDok2b+jw3UYnwV4hbo UNJGgFbLUQQ5Dc5TqOIcPzFDgeaOphYYd2huHkgJHLyvwGp4X+tP28+TBdVXE9DvPmnw R+Ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=CZgj9M1imSNdeUsZYyaFxDLxs0ppgxvpuK429eq2WMM=; b=TQJmLjdHL8mapa0E4j+9C/EUrHoSJDMO9IQa7JMU/zdv8ptuOEW7vsTjVpQjogPkae eGGwgw+s7UL+B8iIY7cTsyX9MlC7+89Uz66QS/nOddZNpPGnEZ4tuDD96sKozhtph+YN bKSyujU186oVzlQb36lh9cCj0kGrOBL8Y3esdWu3jJ7K9crJobHyLaINn1BWlD8KX/K3 0CS8lHoADcMkaBimzReoEkSsjpyNHXVXo9eVGU+hBOpGAwmVFg7pjRLZKOR+k1R9GWKq 9qlzDotEZGyMepi2GoqxlnqlW1VmzuVwt6xaXDcVxGQ4gR8053JB4UgWPkryIbmXELGr 6YFg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w3si1213893pgb.419.2018.02.28.08.40.30; Wed, 28 Feb 2018 08:40:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933111AbeB1Qjv (ORCPT + 99 others); Wed, 28 Feb 2018 11:39:51 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:34796 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934108AbeB1QD6 (ORCPT ); Wed, 28 Feb 2018 11:03:58 -0500 Received: from [2a02:8011:400e:2:6f00:88c8:c921:d332] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1er3Yk-0006Xk-5i; Wed, 28 Feb 2018 15:22:22 +0000 Received: from ben by deadeye with local (Exim 4.90_1) (envelope-from ) id 1er3Yj-0000DY-01; Wed, 28 Feb 2018 15:22:21 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "David S. Miller" , "Christophe JAILLET" Date: Wed, 28 Feb 2018 15:20:18 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 183/254] mdio-sun4i: Fix a memory leak In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:6f00:88c8:c921:d332 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.55-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Christophe JAILLET commit 56c0290202ab94a2f2780c449395d4ae8495fab4 upstream. 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 Signed-off-by: David S. Miller Signed-off-by: Ben Hutchings --- drivers/net/phy/mdio-sun4i.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/net/phy/mdio-sun4i.c +++ b/drivers/net/phy/mdio-sun4i.c @@ -128,8 +128,10 @@ static int sun4i_mdio_probe(struct platf 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;