summaryrefslogtreecommitdiff
path: root/drivers/misc
diff options
context:
space:
mode:
authorFelix Gu <gu_0233@qq.com>2025-12-26 18:22:43 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-12-29 11:59:06 +0100
commitdad9f13d967b4e53e8eaf5f9c690f8e778ad9802 (patch)
treedcf68a8df1349be4305d48b08da62cf4ca1b5a8f /drivers/misc
parent40fc797ba18328e57ed1cb213b4b5e48f86f4c7c (diff)
downloadlwn-dad9f13d967b4e53e8eaf5f9c690f8e778ad9802.tar.gz
lwn-dad9f13d967b4e53e8eaf5f9c690f8e778ad9802.zip
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: 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>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/ti_fpc202.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/misc/ti_fpc202.c b/drivers/misc/ti_fpc202.c
index 7964e46c7448..8eb2b5ac9850 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)