Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fa310789 authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by David S. Miller
Browse files

net: ucc_geth: drop acquired references in probe error path and remove



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: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 129cc83a
Loading
Loading
Loading
Loading
+8 −1
Original line number Original line Diff line number Diff line
@@ -3862,8 +3862,11 @@ static int ucc_geth_probe(struct platform_device* ofdev)
	/* Create an ethernet device instance */
	/* Create an ethernet device instance */
	dev = alloc_etherdev(sizeof(*ugeth));
	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;
		return -ENOMEM;
	}


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


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


	return 0;
	return 0;
}
}