Skip to content
/ linux Public

Commit d297560

Browse files
Felix GuSasha Levin
authored andcommitted
misc: ti_fpc202: fix a potential memory leak in probe function
[ Upstream commit dad9f13 ] 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: Felix Gu <gu_0233@qq.com> Reviewed-by: Romain Gantois <romain.gantois@bootlin.com> Link: https://patch.msgid.link/tencent_FA1AC670F5CF49873F88A44424F866994A08@qq.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent b6cfbd4 commit d297560

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/misc/ti_fpc202.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ static void fpc202_remove_port(struct fpc202_priv *priv, int port_id)
309309
static int fpc202_probe(struct i2c_client *client)
310310
{
311311
struct device *dev = &client->dev;
312-
struct device_node *i2c_handle;
313312
struct fpc202_priv *priv;
314313
int ret, port_id;
315314

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

358357
bitmap_zero(priv->probed_ports, FPC202_NUM_PORTS);
359358

360-
for_each_child_of_node(dev->of_node, i2c_handle) {
359+
for_each_child_of_node_scoped(dev->of_node, i2c_handle) {
361360
ret = of_property_read_u32(i2c_handle, "reg", &port_id);
362361
if (ret) {
363362
if (ret == -EINVAL)

0 commit comments

Comments
 (0)