mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wensheng Liu <961342126@qq.com>
To: sre@kernel.org
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Vencent Liu <961342126@qq.com>
Subject: [PATCH] power: supply: Fix resource leak in ltc2941-battery-gauge.c
Date: Thu, 14 Aug 2025 15:39:55 +0800	[thread overview]
Message-ID: <tencent_6983C78DFAA337B6895389FD937D5C73F608@qq.com> (raw)

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


                 reply	other threads:[~2025-08-14  7:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tencent_6983C78DFAA337B6895389FD937D5C73F608@qq.com \
    --to=961342126@qq.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=sre@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®