FAILED: patch "[PATCH] power: supply: ltc2941: Fix of_node reference leak in ltc294x_i2c_probe()" failed to apply to 5.15-stable tree
Subsystems (2)
Sasha Levin
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 09a29213bf15630e85a375478832b074b2cfc5c8
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 5.15.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From 09a29213bf15630e85a375478832b074b2cfc5c8 Mon Sep 17 00:00:00 2001
From: Wentao Liang <[email protected]>
Date: Thu, 17 Sep 2026 14:21:27 +0000
Subject: [PATCH] power: supply: ltc2941: Fix of_node reference leak in
ltc294x_i2c_probe()
ltc294x_i2c_probe() takes a reference on the device node with of_node_get(), but never drops it, so the reference leaks on every return path, including the success path.
The node is only used to read the battery properties and to set info->supply_desc.name, so release it after its last use and also on the lltc,resistor-sense error path.
--- drivers/power/supply/ltc2941-battery-gauge.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/power/supply/ltc2941-battery-gauge.c +5 -1
@@ -464,9 +464,11 @@ static int ltc294x_i2c_probe(struct i2c_client *client)/* r_sense can be negative, when sense+ is connected to the battery * instead of the sense-. This results in reversed measurements. */ ret =of_property_read_s32 (np,"lltc,resistor-sense" , &r_sense); -if (ret <0 ) +if (ret <0 ) { +of_node_put (np);return dev_err_probe (&client->dev, ret,"Could not find lltc,resistor-sense in devicetree\n" ); + } info->r_sense = r_sense; ret = of_property_read_u32(np, "lltc,prescaler-exponent",
@@ -477,6 +479,8 @@ static int ltc294x_i2c_probe(struct i2c_client *client) prescaler_exp =LTC2941_MAX_PRESCALER_EXP ; } +of_node_put (np); +if (info->id ==LTC2943_ID ) {if (prescaler_exp >LTC2943_MAX_PRESCALER_EXP ) prescaler_exp =LTC2943_MAX_PRESCALER_EXP ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 power: supply: ltc2941: Fix of_node reference leak in ltc294x_i2c_probe()
From: Wentao Liang <[email protected]>
[ Upstream commit 09a29213bf15630e85a375478832b074b2cfc5c8 ]
ltc294x_i2c_probe() takes a reference on the device node with of_node_get(), but never drops it, so the reference leaks on every return path, including the success path.
The node is only used to read the battery properties and to set info->supply_desc.name, so release it after its last use and also on the lltc,resistor-sense error path.
--- drivers/power/supply/ltc2941-battery-gauge.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/power/supply/ltc2941-battery-gauge.c +3 -0
@@ -473,6 +473,7 @@ static int ltc294x_i2c_probe(struct i2c_client *client,* instead of the sense-. This results in reversed measurements. */ ret =of_property_read_u32 (np,"lltc,resistor-sense" , &r_sense);if (ret <0 ) { +of_node_put (np);dev_err (&client->dev,"Could not find lltc,resistor-sense in devicetree\n" );return ret;
@@ -487,6 +488,8 @@ static int ltc294x_i2c_probe(struct i2c_client *client, prescaler_exp =LTC2941_MAX_PRESCALER_EXP ; } +of_node_put (np); +if (info->id ==LTC2943_ID ) {if (prescaler_exp >LTC2943_MAX_PRESCALER_EXP ) prescaler_exp =LTC2943_MAX_PRESCALER_EXP ;
Signature · 1 line
2.53.0