[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230923114807.2829188-1-harshit.m.mogalapalli@oracle.com>
Date: Sat, 23 Sep 2023 04:48:06 -0700
From: Harshit Mogalapalli <harshit.m.mogalapalli@...cle.com>
To: Konrad Dybcio <konradybcio@...nel.org>,
Sebastian Reichel <sre@...nel.org>, linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: dan.carpenter@...aro.org, kernel-janitors@...r.kernel.org,
error27@...il.com, harshit.m.mogalapalli@...cle.com,
kernel test robot <lkp@...el.com>
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 <lkp@...el.com>
Reported-by: Dan Carpenter <error27@...il.com>
Closes: https://lore.kernel.org/r/202309190838.eu8WS6sz-lkp@intel.com/
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@...cle.com>
---
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
Powered by blists - more mailing lists