Commit dad9f13d authored by Felix Gu's avatar Felix Gu Committed by Greg Kroah-Hartman
Browse files

misc: ti_fpc202: fix a potential memory leak in probe function



Use for_each_child_of_node_scoped() to simplify the code and ensure the
device node reference is automatically released when the loop scope
ends.

Signed-off-by: default avatarFelix Gu <gu_0233@qq.com>
Reviewed-by: default avatarRomain Gantois <romain.gantois@bootlin.com>
Link: https://patch.msgid.link/tencent_FA1AC670F5CF49873F88A44424F866994A08@qq.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 40fc797b
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -309,7 +309,6 @@ static void fpc202_remove_port(struct fpc202_priv *priv, int port_id)
static int fpc202_probe(struct i2c_client *client)
{
	struct device *dev = &client->dev;
	struct device_node *i2c_handle;
	struct fpc202_priv *priv;
	int ret, port_id;

@@ -357,7 +356,7 @@ static int fpc202_probe(struct i2c_client *client)

	bitmap_zero(priv->probed_ports, FPC202_NUM_PORTS);

	for_each_child_of_node(dev->of_node, i2c_handle) {
	for_each_child_of_node_scoped(dev->of_node, i2c_handle) {
		ret = of_property_read_u32(i2c_handle, "reg", &port_id);
		if (ret) {
			if (ret == -EINVAL)