Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3797364ybi; Mon, 29 Jul 2019 12:49:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqwpFxJZO5dPkP13jeEHK4xSZfF/Z2kfpOtXs8IzOApnhfYYygv5VsTxCR/5EzxgAfAmaJ/C X-Received: by 2002:a17:90a:d14a:: with SMTP id t10mr73892295pjw.85.1564429766733; Mon, 29 Jul 2019 12:49:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564429766; cv=none; d=google.com; s=arc-20160816; b=Tgc3uOOwaD3b/NwDY8ShrYxB1h1XlWQQofv/R/eu66Fuso16s3uRH0iAhNs30VdC0b Yl20KhxLx0e5SMTIeUQybG9dOfSK0jv5b3BKMLlTLALkGpsSwW6kJ2fbCcDZVUfo5y/E Bh++Fgp40f1fc0CJQrDwbmwk1+9cwf/X/suD0cQhvztlauaJyXzyHuidepGBvyYxQqxp CXuWHZxa3ysBX5L8pc8Y532qPmQUFPrtXazBhAZQmRYisYxjJjc25qpS/k0EuFTXu+Gw BW5HQ3VA0tRnd2jMbhGXdEyR8PaswwaNzjGHB0gJChZi94syiqUI2Su9Ow4+LiizAo22 VJgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zzDjc0ZISwE/dc2ND8vGFtNO/+iwmu/eOeGQmzI0S6k=; b=FYJomJYabqrbya3ak5t/lOpi82WWRCAueMe0y6kZ9wEAD3BMaQ63enwQADkkFmdru9 9nOhGBgo+DF7QB7Hu06i3/5dRo6RXr+UMUFkEEfAir5CQebWLeuHSqibTHJrgoZKezrN e3jllJswrkRqSl13gd/kodEb6O2yBKrbIXVUXXHuhTFbeZ6kN74z1tluGDvEIty8540V NwnrWLlUtF8ePC5oXIHC7giygGtvn6Yb4ugMWp4KICDCRL9/pobcWLeU3YIhJ7E963vK 6idT+pi/ppfabqgtsrdMuQk1+0IW2rFm01obuv8dLTfV7vvLRcupoynAB3aD353iGN7+ RpUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="JQ/ZG+DX"; 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 z27si16098300pfj.225.2019.07.29.12.49.11; Mon, 29 Jul 2019 12:49:26 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b="JQ/ZG+DX"; 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 S2390399AbfG2Tr6 (ORCPT + 99 others); Mon, 29 Jul 2019 15:47:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:37768 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390388AbfG2Try (ORCPT ); Mon, 29 Jul 2019 15:47:54 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2D1A52054F; Mon, 29 Jul 2019 19:47:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429673; bh=5j+OMtqYWQdxW7IWocSN2k+G39CzIhu6wV5/P5JzbDI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JQ/ZG+DXqMLk3qD8FWe1azdNNJ0n/L7yKP1zTkicqOYTe8tM4CbWdUWSYR7M0wq6r 8WvXflVuX13FKWW4bDf711yRUcDNjKrt3726qOGlGvKz3t3VrT7lQkOH2ioz6+LuyZ KkQpNIZYYvHUXRa+0FsEtHhBlw05ZpKraSYyioBI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Julia Lawall , Yoshihiro Shimoda , Geert Uytterhoeven , Kishon Vijay Abraham I , Sasha Levin Subject: [PATCH 5.2 058/215] phy: renesas: rcar-gen2: Fix memory leak at error paths Date: Mon, 29 Jul 2019 21:20:54 +0200 Message-Id: <20190729190750.571643093@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit d4a36e82924d3305a17ac987a510f3902df5a4b2 ] This patch fixes memory leak at error paths of the probe function. In for_each_child_of_node, if the loop returns, the driver should call of_put_node() before returns. Reported-by: Julia Lawall Fixes: 1233f59f745b237 ("phy: Renesas R-Car Gen2 PHY driver") Signed-off-by: Yoshihiro Shimoda Reviewed-by: Geert Uytterhoeven Signed-off-by: Kishon Vijay Abraham I Signed-off-by: Sasha Levin --- drivers/phy/renesas/phy-rcar-gen2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/phy/renesas/phy-rcar-gen2.c b/drivers/phy/renesas/phy-rcar-gen2.c index 8dc5710d9c98..2926e4937301 100644 --- a/drivers/phy/renesas/phy-rcar-gen2.c +++ b/drivers/phy/renesas/phy-rcar-gen2.c @@ -391,6 +391,7 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev) error = of_property_read_u32(np, "reg", &channel_num); if (error || channel_num > 2) { dev_err(dev, "Invalid \"reg\" property\n"); + of_node_put(np); return error; } channel->select_mask = select_mask[channel_num]; @@ -406,6 +407,7 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev) data->gen2_phy_ops); if (IS_ERR(phy->phy)) { dev_err(dev, "Failed to create PHY\n"); + of_node_put(np); return PTR_ERR(phy->phy); } phy_set_drvdata(phy->phy, phy); -- 2.20.1