2023-09-23 13:57:03

by Harshit Mogalapalli

[permalink] [raw]
Subject: [PATCH next] power: supply: mm8013: Fix error code in mm8013_probe()

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 <[email protected]>
Reported-by: Dan Carpenter <[email protected]>
Closes: https://lore.kernel.org/r/[email protected]/
Signed-off-by: Harshit Mogalapalli <[email protected]>
---
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


2023-09-25 02:29:00

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [PATCH next] power: supply: mm8013: Fix error code in mm8013_probe()


On Sat, 23 Sep 2023 04:48:06 -0700, Harshit Mogalapalli wrote:
> 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().
>
>

Applied, thanks!

[1/1] power: supply: mm8013: Fix error code in mm8013_probe()
commit: 43ee22422db545800b8bf2c24ef53d040372fc7a

Best regards,
--
Sebastian Reichel <[email protected]>