Skip to content

Commit

Permalink
net: ucc_geth: drop acquired references in probe error path and remove
Browse files Browse the repository at this point in the history
The ucc_geth_probe function assigns to ug_info->tbi_node and
ug_info->phy_node a value returned by of_parse_phandle which returns a
new reference. Put this reference again in the error path of
ucc_geth_probe and when removing the device.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Uwe Kleine-König authored and David S. Miller committed Aug 7, 2014
1 parent 129cc83 commit fa31078
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion drivers/net/ethernet/freescale/ucc_geth.c
Original file line number Diff line number Diff line change
Expand Up @@ -3862,8 +3862,11 @@ static int ucc_geth_probe(struct platform_device* ofdev)
/* Create an ethernet device instance */
dev = alloc_etherdev(sizeof(*ugeth));

if (dev == NULL)
if (dev == NULL) {
of_node_put(ug_info->tbi_node);
of_node_put(ug_info->phy_node);
return -ENOMEM;
}

ugeth = netdev_priv(dev);
spin_lock_init(&ugeth->lock);
Expand Down Expand Up @@ -3897,6 +3900,8 @@ static int ucc_geth_probe(struct platform_device* ofdev)
pr_err("%s: Cannot register net device, aborting\n",
dev->name);
free_netdev(dev);
of_node_put(ug_info->tbi_node);
of_node_put(ug_info->phy_node);
return err;
}

Expand All @@ -3920,6 +3925,8 @@ static int ucc_geth_remove(struct platform_device* ofdev)
unregister_netdev(dev);
free_netdev(dev);
ucc_geth_memclean(ugeth);
of_node_put(ugeth->info->tbi_node);
of_node_put(ugeth->info->phy_node);

return 0;
}
Expand Down

0 comments on commit fa31078

Please sign in to comment.