Skip to content

Commit 989e4da

Browse files
Sylfrenadavem330
authored andcommitted
net: gianfar: Add of_node_put() before goto statement
Every iteration of for_each_available_child_of_node() decrements reference count of the previous node, however when control is transferred from the middle of the loop, as in the case of a return or break or goto, there is no decrement thus ultimately resulting in a memory leak. Fix a potential memory leak in gianfar.c by inserting of_node_put() before the goto statement. Issue found with Coccinelle. Signed-off-by: Sumera Priyadarsini <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5680790 commit 989e4da

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/net/ethernet/freescale/gianfar.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,8 +750,10 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
750750
continue;
751751

752752
err = gfar_parse_group(child, priv, model);
753-
if (err)
753+
if (err) {
754+
of_node_put(child);
754755
goto err_grp_init;
756+
}
755757
}
756758
} else { /* SQ_SG_MODE */
757759
err = gfar_parse_group(np, priv, model);

0 commit comments

Comments
 (0)