Skip to contentSkip to conversation

mfd: pm8008: Fix return value check in pm8008_probe()

PATCH Superseded Yang Yingliang 3 participants 5 messages Jun 3, 2021 – Jun 4, 2021

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 drivers/mfd/qcom-pm8008.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/qcom-pm8008.c +1 -1
index c472d7f8103c..dfefa60d693b 100644
@@ -223,7 +223,7 @@ static int pm8008_probe(struct i2c_client *client)
 	struct pm8008_data *chip;
 
 	chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
-	if (!chip)
+	if (IS_ERR(chip))
 		return -ENOMEM;
 
 	chip->dev = &client->dev;
Signature · 1 line
2.25.1
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Yang Yingliang

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")
Quoted 20 lines
---
 drivers/mfd/qcom-pm8008.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/qcom-pm8008.c +1 -1
index c472d7f8103c..dfefa60d693b 100644
@@ -223,7 +223,7 @@ static int pm8008_probe(struct i2c_client *client)
 	struct pm8008_data *chip;
 
 	chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
-	if (!chip)
+	if (IS_ERR(chip))
 		return -ENOMEM;
 
 	chip->dev = &client->dev;
Signature · 1 line
2.25.1
#2 lore raw
Quoted 11 lines · Guru Das Srinagesh
Quoted 7 lines · Yang Yingliang

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")

Interestingly, the change does not correspond to the changelog message. And the code is correct as devm_kzalloc returns NULL if I remember correctly.

Quoted 21 lines
Quoted 21 lines
---
 drivers/mfd/qcom-pm8008.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/qcom-pm8008.c +1 -2
index c472d7f8103c..dfefa60d693b 100644
@@ -223,7 +223,7 @@ static int pm8008_probe(struct i2c_client *client)
      struct pm8008_data *chip;
 
      chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
-     if (!chip)
+     if (IS_ERR(chip))
              return -ENOMEM;
 
      chip->dev = &client->dev;
--

2.25.1

Signature · 2 lines
With best wishes
Dmitry
#3 lore raw
Quoted 11 lines · Dmitry Baryshkov
Quoted 10 lines · Guru Das Srinagesh
Quoted 7 lines · Yang Yingliang

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")
Quoted 5 lines
Quoted 1 line

Interestingly, the change does not correspond to the changelog message. And the code is correct as devm_kzalloc returns NULL if I remember correctly.

Thanks for pointing that out - I missed that. I would like to retract my Acked-by for this patch.

Quoted 28 lines
Quoted 22 lines
Quoted 22 lines

---
 drivers/mfd/qcom-pm8008.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/qcom-pm8008.c +1 -2
index c472d7f8103c..dfefa60d693b 100644
@@ -223,7 +223,7 @@ static int pm8008_probe(struct i2c_client *client)
      struct pm8008_data *chip;
 
      chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
-     if (!chip)
+     if (IS_ERR(chip))
              return -ENOMEM;
 
      chip->dev = &client->dev;
--

2.25.1

Signature · 2 lines
With best wishes
Dmitry
#4 lore raw
Quoted 7 lines · Guru Das Srinagesh
Quoted 6 lines · Dmitry Baryshkov
Quoted 5 lines · Guru Das Srinagesh
Quoted 4 lines · Yang Yingliang

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().

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
Fixes 6b149f3310a4 ("mfd: pm8008: Add driver for QCOM PM8008 PMIC")

Interestingly, the change does not correspond to the changelog message. And the code is correct as devm_kzalloc returns NULL if I remember correctly.

My bad, I sent a wong patch, I will send a new one.

Thanks,
Yang

Quoted 29 lines

Thanks for pointing that out - I missed that. I would like to retract my Acked-by for this patch.

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
---
  drivers/mfd/qcom-pm8008.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/qcom-pm8008.c +1 -1
index c472d7f8103c..dfefa60d693b 100644
@@ -223,7 +223,7 @@ static int pm8008_probe(struct i2c_client *client)
       struct pm8008_data *chip;
 
       chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
-     if (!chip)
+     if (IS_ERR(chip))
               return -ENOMEM;
 
Quoted 9 lines
Quoted 4 lines
Quoted 4 lines
drivers/mfd/qcom-pm8008.c +0 -1
       chip->dev = &client->dev;
--

2.25.1

Signature · 2 lines
With best wishes
Dmitry

.