]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iio: adc: ad4030: fix error pointer dereference in probe()
authorDan Carpenter <dan.carpenter@linaro.org>
Fri, 28 Feb 2025 09:35:40 +0000 (12:35 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Tue, 4 Mar 2025 14:52:42 +0000 (14:52 +0000)
The intention here was obviously to return an error if devm_regmap_init()
fails, but the return statement was accidentally left out.  This leads to
an error pointer dereference when we call:

ret = ad4030_detect_chip_info(st);

Add the return statement.

Fixes: ec25cf6f1ee3 ("iio: adc: ad4030: add support for ad4632-16 and ad4632-24")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/cc67cee7-9c65-46d2-aae3-f860fc3cc461@stanley.mountain
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/ad4030.c

index 209cfc2e17850a3cecf75dc40c3ba60a9ed32e63..9a020680885d93f4da8922e5cfeecc0c7ce23f4d 100644 (file)
@@ -1011,8 +1011,8 @@ static int ad4030_probe(struct spi_device *spi)
        st->regmap = devm_regmap_init(dev, &ad4030_regmap_bus, st,
                                      &ad4030_regmap_config);
        if (IS_ERR(st->regmap))
-               dev_err_probe(dev, PTR_ERR(st->regmap),
-                             "Failed to initialize regmap\n");
+               return dev_err_probe(dev, PTR_ERR(st->regmap),
+                                    "Failed to initialize regmap\n");
 
        st->chip = spi_get_device_match_data(spi);
        if (!st->chip)