]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
button: qcom-pmic: fix some error checking
authorDan Carpenter <dan.carpenter@linaro.org>
Wed, 31 Jan 2024 07:09:15 +0000 (10:09 +0300)
committerCaleb Connolly <caleb.connolly@linaro.org>
Wed, 14 Feb 2024 17:16:52 +0000 (17:16 +0000)
The pmic_reg_read() function can return errors.  Add a check for that.

Fixes: 4e8aa0065d4b ("button: qcom-pmic: introduce Qualcomm PMIC button driver")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Caleb Connolly <caleb.connolly@linaro.org>
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
drivers/button/button-qcom-pmic.c

index 34a976d1e6c6a9db951305f02edc0f7fb29272d7..e778e51a4f36c270961f38815dfd4e7cc76286b9 100644 (file)
@@ -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;
        }