Skip to content

Commit 718514c

Browse files
shimodaygregkh
authored andcommitted
phy: renesas: rcar-gen2: Fix memory leak at error paths
[ Upstream commit d4a36e8 ] 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 <julia.lawall@lip6.fr> Fixes: 1233f59 ("phy: Renesas R-Car Gen2 PHY driver") Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 25d2b1b commit 718514c

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/phy/phy-rcar-gen2.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev)
287287
error = of_property_read_u32(np, "reg", &channel_num);
288288
if (error || channel_num > 2) {
289289
dev_err(dev, "Invalid \"reg\" property\n");
290+
of_node_put(np);
290291
return error;
291292
}
292293
channel->select_mask = select_mask[channel_num];
@@ -302,6 +303,7 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev)
302303
&rcar_gen2_phy_ops);
303304
if (IS_ERR(phy->phy)) {
304305
dev_err(dev, "Failed to create PHY\n");
306+
of_node_put(np);
305307
return PTR_ERR(phy->phy);
306308
}
307309
phy_set_drvdata(phy->phy, phy);

0 commit comments

Comments
 (0)