Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4102926ybi; Mon, 29 Jul 2019 19:18:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqzGirWAOdrCh9JZHZUSwhQbdXWRIE6/lutHw1NfPzsch5HtnOCAuU39TIpcqgmqcoE83y3A X-Received: by 2002:a17:902:e306:: with SMTP id cg6mr113044835plb.263.1564453109995; Mon, 29 Jul 2019 19:18:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564453109; cv=none; d=google.com; s=arc-20160816; b=pZWbjQv0vvUSUT8TDprvvyy17CLV3nMJj5uGXoR4JgoXB74To/9cyisCI5uAiw+vRX bcaWmWohz9UKOAEnyivQ8sLjqSGCtuRAsnzqHI3jB5AeFqPNVI5wxB9uKCHj8Ho6/dgd +xJbOF3oZaeVcUOiRG3HEF5DKT2gAGUCKjlt495qlOyPt8QPpN6wv88FdGDgh8y1PoAx EznkeN16SKaAQys2uWXjaY+4CVQQUpmAxteEAW5uFcaYE65Tfebt6g+J8o0BhHVBmEwY arJlLWbdtOTi1N8OF5xoOiThGqS5LotifUOVC9CVw8De9Uiri008gWV0OqR6mifkrqwM aiaQ== 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=0uA0WvEcsag+rfBQ8hmTCJ64tJB795UojAa/MOmTv20=; b=xLyPiCzxXzBRY3ZbHD/csmYf9f8yFdgOrZFog0LK5xfeGKiLqzaz+2rnduNBkems1l VWagnPIHmmNMcNd90YlXOXUO9MPBMJlIkAyphs846EEu2oJputfnpRpt2CUQ21yw3Dv1 LU/+qzpTaUBqd5r4ooTGvPtkLWpFxuc8kA/7WEM5yYnYwgku7ztQipMVc6VUSpG7dOwZ OufsGIrFNY0Txim7imI3j2NtvBZqExPXhaZJQCSy8+ETu9BBceFYTy9ageQVeRHVRj7Y agJQ3O7DJGeeIbP4MuNmO3ERxc1AoFv//Yc7uiAwrjpJrGBFkFllchO58UVpnf1HHCAJ Y3rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="os29/b+1"; 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 v9si24639896plp.4.2019.07.29.19.18.14; Mon, 29 Jul 2019 19:18:29 -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="os29/b+1"; 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 S2389149AbfG2TkV (ORCPT + 99 others); Mon, 29 Jul 2019 15:40:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:55624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389133AbfG2TkT (ORCPT ); Mon, 29 Jul 2019 15:40:19 -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 A621F21773; Mon, 29 Jul 2019 19:40:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429218; bh=H5VIOUyEePA3e7YILjunOmQC973IRxnSoT1mO4GezMc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=os29/b+1DlTp0uhJxn8q325B1bemEUbye6BuWHPwxZfLKLtnAQBMDHOY/kfjopKVA 1e+xFaqfETviaPnAM/BzS6QACpvRkEUHvQBRVFWIIcFFdhEAinOVgruay6//pMMHXz E4JaDjgYjaU2ev7a2PW2KO7RsInVKtmeg8ujWF94= 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 4.19 028/113] phy: renesas: rcar-gen2: Fix memory leak at error paths Date: Mon, 29 Jul 2019 21:21:55 +0200 Message-Id: <20190729190702.607476799@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190655.455345569@linuxfoundation.org> References: <20190729190655.455345569@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 97d4dd6ea924..aa02b19b7e0e 100644 --- a/drivers/phy/renesas/phy-rcar-gen2.c +++ b/drivers/phy/renesas/phy-rcar-gen2.c @@ -288,6 +288,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]; @@ -303,6 +304,7 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev) &rcar_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