[PATCH next] power: supply: mm8013: Fix error code in mm8013_probe()
From: Harshit Mogalapalli
Date: Sat Sep 23 2023 - 07:48:28 EST
The value of ret is zero when passed to dev_error_probe(), we are passing
zero to dev_err_probe() is a success which is incorrect.
Fix this by getting the error code using PTR_ERR().
Fixes: c75f4bf6800b ("power: supply: Introduce MM8013 fuel gauge driver")
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <error27@xxxxxxxxx>
Closes: https://lore.kernel.org/r/202309190838.eu8WS6sz-lkp@xxxxxxxxx/
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@xxxxxxxxxx>
---
This is based on static analysis with smatch, only compile tested.
---
drivers/power/supply/mm8013.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/power/supply/mm8013.c b/drivers/power/supply/mm8013.c
index ddac40ef9ae5..29fd65fe6545 100644
--- a/drivers/power/supply/mm8013.c
+++ b/drivers/power/supply/mm8013.c
@@ -273,8 +273,10 @@ static int mm8013_probe(struct i2c_client *client)
chip->client = client;
chip->regmap = devm_regmap_init_i2c(client, &mm8013_regmap_config);
- if (IS_ERR(chip->regmap))
+ if (IS_ERR(chip->regmap)) {
+ ret = PTR_ERR(chip->regmap);
return dev_err_probe(dev, ret, "Couldn't initialize regmap\n");
+ }
ret = mm8013_checkdevice(chip);
if (ret)
--
2.39.3