2021-06-04 01:37:45

by Yang Yingliang

[permalink] [raw]
Subject: [PATCH -next v2] mfd: pm8008: Fix return value check in pm8008_probe()

In case of error, the function devm_regmap_init_i2c() returns ERR_PTR()
and never returns NULL. The NULL test in the return value check
should be replaced with IS_ERR().

Fixes: 6b149f3310a4 ("mfd: pm8008: Add driver for QCOM PM8008 PMIC")
Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Yang Yingliang <[email protected]>
---
v2:
make the change correspond to the changelog
---
drivers/mfd/qcom-pm8008.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/qcom-pm8008.c b/drivers/mfd/qcom-pm8008.c
index c472d7f8103c..476171455d32 100644
--- a/drivers/mfd/qcom-pm8008.c
+++ b/drivers/mfd/qcom-pm8008.c
@@ -228,7 +228,7 @@ static int pm8008_probe(struct i2c_client *client)

chip->dev = &client->dev;
chip->regmap = devm_regmap_init_i2c(client, &qcom_mfd_regmap_cfg);
- if (!chip->regmap)
+ if (IS_ERR(chip->regmap))
return -ENODEV;

i2c_set_clientdata(client, chip);
--
2.25.1


2021-06-04 17:52:24

by Guru Das Srinagesh

[permalink] [raw]
Subject: Re: [PATCH -next v2] mfd: pm8008: Fix return value check in pm8008_probe()

On Fri, Jun 04, 2021 at 09:38:24AM +0800, Yang Yingliang wrote:
> In case of error, the function devm_regmap_init_i2c() returns ERR_PTR()
> and never returns NULL. The NULL test in the return value check
> should be replaced with IS_ERR().
>
> Fixes: 6b149f3310a4 ("mfd: pm8008: Add driver for QCOM PM8008 PMIC")
> Reported-by: Hulk Robot <[email protected]>
> Signed-off-by: Yang Yingliang <[email protected]>
> ---
> v2:
> make the change correspond to the changelog
> ---
> drivers/mfd/qcom-pm8008.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mfd/qcom-pm8008.c b/drivers/mfd/qcom-pm8008.c
> index c472d7f8103c..476171455d32 100644
> --- a/drivers/mfd/qcom-pm8008.c
> +++ b/drivers/mfd/qcom-pm8008.c
> @@ -228,7 +228,7 @@ static int pm8008_probe(struct i2c_client *client)
>
> chip->dev = &client->dev;
> chip->regmap = devm_regmap_init_i2c(client, &qcom_mfd_regmap_cfg);
> - if (!chip->regmap)
> + if (IS_ERR(chip->regmap))
> return -ENODEV;

The error received from devm_regmap_init_i2c should be returned as-is and not
-ENODEV. Could you please do:

if (IS_ERR(chip->regmap))
return PTR_ERR(chip->regmap);

Thank you for this patch.

>
> i2c_set_clientdata(client, chip);