[PATCH 6.19 382/844] misc: ti_fpc202: fix a potential memory leak in probe function
From: Sasha Levin
Date: Sat Feb 28 2026 - 13:48:58 EST
From: Felix Gu <gu_0233@xxxxxx>
[ Upstream commit dad9f13d967b4e53e8eaf5f9c690f8e778ad9802 ]
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@xxxxxx>
Reviewed-by: Romain Gantois <romain.gantois@xxxxxxxxxxx>
Link: https://patch.msgid.link/tencent_FA1AC670F5CF49873F88A44424F866994A08@xxxxxx
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
drivers/misc/ti_fpc202.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/misc/ti_fpc202.c b/drivers/misc/ti_fpc202.c
index 7964e46c74482..8eb2b5ac98506 100644
--- a/drivers/misc/ti_fpc202.c
+++ b/drivers/misc/ti_fpc202.c
@@ -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)
--
2.51.0