[next] power: supply: mm8013: Fix error code in mm8013_probe()

Message ID 20230923114807.2829188-1-harshit.m.mogalapalli@oracle.com
State New
Headers
Series [next] power: supply: mm8013: Fix error code in mm8013_probe() |

Commit Message

Harshit Mogalapalli Sept. 23, 2023, 11:48 a.m. UTC
  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@intel.com>
Reported-by: Dan Carpenter <error27@gmail.com>
Closes: https://lore.kernel.org/r/202309190838.eu8WS6sz-lkp@intel.com/
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.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(-)
  

Comments

Sebastian Reichel Sept. 24, 2023, 8:58 p.m. UTC | #1
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,
  

Patch

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)