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

From: Zongmin Zhou

Date: Wed Aug 26 2026 - 22:06:46 EST


From: Zongmin Zhou <zhouzongmin@xxxxxxxxxx>

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@xxxxxxxxxxxxxx>
Cc: Kaustabh Chakraborty <kauschluss@xxxxxxxxxxx>
Cc: Sebastian Reichel <sebastian.reichel@xxxxxxxxxxxxx>
Signed-off-by: Zongmin Zhou <zhouzongmin@xxxxxxxxxx>
---
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