[<prev] [next>] [day] [month] [year] [list]
Message-ID: <tencent_6983C78DFAA337B6895389FD937D5C73F608@qq.com>
Date: Thu, 14 Aug 2025 15:39:55 +0800
From: Wensheng Liu <961342126@...com>
To: sre@...nel.org
Cc: linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org,
Vencent Liu <961342126@...com>
Subject: [PATCH] power: supply: Fix resource leak in ltc2941-battery-gauge.c
From: Vencent Liu <961342126@...com>
The ltc294x_i2c_probe function increments the reference count
of the device node via of_node_get() but fails to decrement it in several
code paths. This leads to a reference count leak that prevents the device
node from being properly released.
Signed-off-by: Vencent Liu <961342126@...com>
---
drivers/power/supply/ltc2941-battery-gauge.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/power/supply/ltc2941-battery-gauge.c b/drivers/power/supply/ltc2941-battery-gauge.c
index a1ddc4b060ce..64f900d6756d 100644
--- a/drivers/power/supply/ltc2941-battery-gauge.c
+++ b/drivers/power/supply/ltc2941-battery-gauge.c
@@ -19,6 +19,7 @@
#include <linux/delay.h>
#include <linux/power_supply.h>
#include <linux/slab.h>
+#include <linux/cleanup.h>
#define I16_MSB(x) ((x >> 8) & 0xFF)
#define I16_LSB(x) (x & 0xFF)
@@ -443,7 +444,6 @@ static int ltc294x_i2c_probe(struct i2c_client *client)
{
struct power_supply_config psy_cfg = {};
struct ltc294x_info *info;
- struct device_node *np;
int ret;
u32 prescaler_exp;
s32 r_sense;
@@ -455,7 +455,7 @@ static int ltc294x_i2c_probe(struct i2c_client *client)
i2c_set_clientdata(client, info);
- np = of_node_get(client->dev.of_node);
+ struct device_node *np = of_node_get(client->dev.of_node);
info->id = (enum ltc294x_id) (uintptr_t) of_device_get_match_data(
&client->dev);
--
2.43.5
Powered by blists - more mailing lists