linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] power: supply: Fix resource leak in ltc2941-battery-gauge.c
@ 2025-08-14  7:39 Wensheng Liu
  0 siblings, 0 replies; only message in thread
From: Wensheng Liu @ 2025-08-14  7:39 UTC (permalink / raw)
  To: sre; +Cc: linux-pm, linux-kernel, Vencent Liu

From: Vencent Liu <961342126@qq.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@qq.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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2025-08-14  7:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-14  7:39 [PATCH] power: supply: Fix resource leak in ltc2941-battery-gauge.c Wensheng Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).