[PATCH] power: supply: s2mu005-battery: return errors from dev_err_probe() in probe

Zongmin Zhou posted 1 patch 1 month ago
drivers/power/supply/s2mu005-battery.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] power: supply: s2mu005-battery: return errors from dev_err_probe() in probe
Posted by Zongmin Zhou 1 month ago
From: Zongmin Zhou <zhouzongmin@kylinos.cn>

s2mu005_fg_i2c_probe() calls dev_err_probe() when devm_mutex_init() or
devm_request_threaded_irq() fails, but drops the return value and
carries on, finally returning 0. A failed probe is then reported as a
success: the device stays registered with an uninitialized mutex and
without its IRQ handler installed.

Return the error from dev_err_probe() in both places so that the probe
fails and the driver core logs the error state properly.

Fixes: aa2132799817 ("power: supply: add support for S2MU005 battery fuel gauge device")
Cc: Yassine Oudjana <y.oudjana@protonmail.com>
Cc: Kaustabh Chakraborty <kauschluss@disroot.org>
Cc: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Zongmin Zhou <zhouzongmin@kylinos.cn>
---
 drivers/power/supply/s2mu005-battery.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/power/supply/s2mu005-battery.c b/drivers/power/supply/s2mu005-battery.c
index 53de660..a76154e 100644
--- a/drivers/power/supply/s2mu005-battery.c
+++ b/drivers/power/supply/s2mu005-battery.c
@@ -262,7 +262,7 @@ static int s2mu005_fg_i2c_probe(struct i2c_client *client)
 
 	ret = devm_mutex_init(dev, &priv->monout_mutex);
 	if (ret)
-		dev_err_probe(dev, ret, "failed to initialize MONOUT mutex\n");
+		return dev_err_probe(dev, ret, "failed to initialize MONOUT mutex\n");
 
 	psy_desc = device_get_match_data(dev);
 
@@ -277,7 +277,7 @@ static int s2mu005_fg_i2c_probe(struct i2c_client *client)
 					s2mu005_handle_irq, IRQF_ONESHOT,
 					psy_desc->name, priv);
 	if (ret)
-		dev_err_probe(dev, ret, "failed to request IRQ\n");
+		return dev_err_probe(dev, ret, "failed to request IRQ\n");
 
 	return 0;
 }
-- 
2.34.1


No virus found
		Checked by Hillstone Network AntiVirus
Re: [PATCH] power: supply: s2mu005-battery: return errors from dev_err_probe() in probe
Posted by Sebastian Reichel 2 weeks, 3 days ago
On Thu, 27 Aug 2026 10:05:39 +0800, Zongmin Zhou wrote:
> s2mu005_fg_i2c_probe() calls dev_err_probe() when devm_mutex_init() or
> devm_request_threaded_irq() fails, but drops the return value and
> carries on, finally returning 0. A failed probe is then reported as a
> success: the device stays registered with an uninitialized mutex and
> without its IRQ handler installed.
> 
> Return the error from dev_err_probe() in both places so that the probe
> fails and the driver core logs the error state properly.
> 
> [...]

Applied, thanks!

[1/1] power: supply: s2mu005-battery: return errors from dev_err_probe() in probe
      commit: d5146fe3468703d82087270eb18bac81c15c10a6

Best regards,
-- 
Sebastian Reichel <sebastian.reichel@collabora.com>