From: Rodrigo Alencar <[email protected]>

Verify that chip_info pointer is not NULL. If a user binds the driver
using driver_override via sysfs with a device name not present in the
id_table or of_match_table, match data will be NULL.

Fixes: 0eb1728461a1 ("iio: dac: ad5686: drop enum id")
Reported-by: [email protected]
Closes: https://lore.kernel.org/all/[email protected]/
Signed-off-by: Rodrigo Alencar <[email protected]>
---
 drivers/iio/dac/ad5686.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c
index 713fe71ad1e7..d34250647aa4 100644
--- a/drivers/iio/dac/ad5686.c
+++ b/drivers/iio/dac/ad5686.c
@@ -479,6 +479,9 @@ int ad5686_probe(struct device *dev,
        struct iio_dev *indio_dev;
        int ret, i;
 
+       if (!chip_info)
+               return -ENODEV;
+
        indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
        if (indio_dev == NULL)
                return  -ENOMEM;

-- 
2.43.0



Reply via email to