Skip to contentSkip to conversation

button: qcom-pmic: fix some error checking

PATCH Applied Dan Carpenter 3 participants 4 messages Jan 31, 2024 – Feb 14, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 button: qcom-pmic: fix some error checking

The pmic_reg_read() function can return errors. Add a check for that.

Fixes 4e8aa0065d4b ("button: qcom-pmic: introduce Qualcomm PMIC button driver")

---
This patch is mostly to make static checkers happy but it's obvious and harmless.

 drivers/button/button-qcom-pmic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/button/button-qcom-pmic.c +1 -1
index 34a976d1e6c6..e778e51a4f36 100644
@@ -86,7 +86,7 @@ static int qcom_pwrkey_probe(struct udevice *dev)
 	}
 
 	ret = pmic_reg_read(priv->pmic, priv->base + REG_SUBTYPE);
-	if ((ret & 0x7) == 0) {
+	if (ret < 0 || (ret & 0x7) == 0) {
 		printf("%s: unexpected PMCI function subtype %d\n", dev->name, ret);
 		return -ENXIO;
 	}
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Dan Carpenter

The pmic_reg_read() function can return errors. Add a check for that.

Fixes 4e8aa0065d4b ("button: qcom-pmic: introduce Qualcomm PMIC button driver")
Quoted 20 lines

---
This patch is mostly to make static checkers happy but it's obvious and harmless.

 drivers/button/button-qcom-pmic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/button/button-qcom-pmic.c +1 -1
index 34a976d1e6c6..e778e51a4f36 100644
@@ -86,7 +86,7 @@ static int qcom_pwrkey_probe(struct udevice *dev)
 	}
 
 	ret = pmic_reg_read(priv->pmic, priv->base + REG_SUBTYPE);
-	if ((ret & 0x7) == 0) {
+	if (ret < 0 || (ret & 0x7) == 0) {
 		printf("%s: unexpected PMCI function subtype %d\n", dev->name, ret);
 		return -ENXIO;
 	}
Signature · 1 line
// Caleb (they/them)
Reviewed-by on v1 1/1
#2 lore raw
In reply to Dan Carpenter
Quoted 12 lines · Dan Carpenter

The pmic_reg_read() function can return errors. Add a check for that.

Fixes 4e8aa0065d4b ("button: qcom-pmic: introduce Qualcomm PMIC button driver")

---
This patch is mostly to make static checkers happy but it's obvious and harmless.

 drivers/button/button-qcom-pmic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-Sumit

Quoted 16 lines
drivers/button/button-qcom-pmic.c +1 -2
index 34a976d1e6c6..e778e51a4f36 100644
@@ -86,7 +86,7 @@ static int qcom_pwrkey_probe(struct udevice *dev)
        }
 
        ret = pmic_reg_read(priv->pmic, priv->base + REG_SUBTYPE);
-       if ((ret & 0x7) == 0) {
+       if (ret < 0 || (ret & 0x7) == 0) {
                printf("%s: unexpected PMCI function subtype %d\n", dev->name, ret);
                return -ENXIO;
        }
--

2.43.0

#3 lore raw
In reply to Dan Carpenter
Quoted 3 lines · Dan Carpenter

The pmic_reg_read() function can return errors. Add a check for that.

Applied, thanks!

[1/1] button: qcom-pmic: fix some error checking

      commit: 6b929e9f3c16bbddeffb85351e93db13eaa9b57d

Best regards,

Signature · 1 line
// Caleb (they/them)