Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3134002ybi; Thu, 18 Jul 2019 21:41:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqzGMCpJYPVSuIq3okLWCMmPX491XjMcJJXiVcl1bLjDPqqVW8CZvNg3sHOXuVqF7JlbDJ+8 X-Received: by 2002:a63:fe15:: with SMTP id p21mr52359276pgh.149.1563511304088; Thu, 18 Jul 2019 21:41:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563511304; cv=none; d=google.com; s=arc-20160816; b=Vh0SUA6WrCHV8VxorBap/PdLikeCWZ+vdvwpnUWrJtnI+jwVA7iYr1VkX5nVrnPGEn kfSRDYcv3isCevzih4ubBfZlTve9pU9RKSkJMVUdf4O3oUMgVAnhKGre6Ggn6kXxeiN5 9lyyXQMHYM0kdWkYJbO46gY7pjfm31o4FNOg9g64GlSk7YXs2t8EwgNhuqOusGpxCpA0 i552q35WJ61Pt61i42liwsWuE0z5MzIrS/fjQP0eH8MuQzjd8Xq/sB8dLtkZoEEYR8C0 kpXrx8omwkIItDv0RTSP+5iJlPw4w/ySP883A/Ns3QS7FiyHTzFJm5ddPL1I+8WVwDKJ x49Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=82ytCBrms/cwmnIo5jNnhetEzPRr3pyH0Z7uDPr7GvQ=; b=HODuom7++tQD01l8G7iJlzub4AEkGjY7DbUhz1qEH5CvRS17aNy57xidXO7t0mBABL IfnKyIN/geN/ebE/4G6/SGnxP3kHEhbQx0MHrJcHnKK8EIo618AkX1Niu55lej3u4YTo 7p+iVfiL1Tk3HBsJPnh9Ac7BunHGtzn62PuJK0B+BGoeXoSGm174KTIRg78KuLVN6C2R z/ilYXMBK3ahVTN9eAd/g7X4FZJlIxSuPcXH2pnTfFkBJa1nIx4cwCvo9K6YQwuEG0Xo 7N9cH5br5dnJKhQaey1IIrHZhfFB051GLZlUnnXZMS3s8nG3gtLl7lohY3BdwObiPOWW XvOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tqaEcGcX; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z17si4739452pgj.147.2019.07.18.21.41.28; Thu, 18 Jul 2019 21:41:44 -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=tqaEcGcX; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728350AbfGSD64 (ORCPT + 99 others); Thu, 18 Jul 2019 23:58:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:58262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728319AbfGSD6w (ORCPT ); Thu, 18 Jul 2019 23:58:52 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D3C7421850; Fri, 19 Jul 2019 03:58:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508731; bh=ugXhQ/hVC9j4XS4BCtMENuXlMjRXIQFdK/ALTpZTJzU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tqaEcGcXtXdJ9IKTX27s9PzJHIV6RQUwlMve/HyochcQ45jdyYV5rtwldgXrtxDkR lTBwgeLkeWyms7niaV34zhN95PtcDAhZJWb53IF9KdJnh3GZDdDZfrOlNSvlmNKdgk tkyDOi97AoSq60WXbhbrbWW5UjY6SOuUO/ssHRis= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Yoshihiro Shimoda , Julia Lawall , Geert Uytterhoeven , Kishon Vijay Abraham I , Sasha Levin Subject: [PATCH AUTOSEL 5.2 056/171] phy: renesas: rcar-gen2: Fix memory leak at error paths Date: Thu, 18 Jul 2019 23:54:47 -0400 Message-Id: <20190719035643.14300-56-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719035643.14300-1-sashal@kernel.org> References: <20190719035643.14300-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yoshihiro Shimoda [ 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