mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
iio: potentiometer: x9250: reject devices without match data
A device bound through driver_override need not match an entry in the
driver tables. In that case spi_get_device_match_data() returns NULL,
but x9250_probe() later dereferences the result while naming the IIO
device.
Reject devices without match data before enabling the regulators.
Fixes: 66bfc528a6 ("iio: potentiometer: Add support for the Renesas X9250 potentiometers")
Signed-off-by: Jiale Yao <yaojiale02@163.com>
Cc: stable@vger.kernel.org
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
This commit is contained in:
parent
2c01a0a1c5
commit
d13716e3de
|
|
@ -155,10 +155,15 @@ static const char *const x9250_regulator_names[] = {
|
|||
|
||||
static int x9250_probe(struct spi_device *spi)
|
||||
{
|
||||
const struct x9250_cfg *cfg;
|
||||
struct iio_dev *indio_dev;
|
||||
struct x9250 *x9250;
|
||||
int ret;
|
||||
|
||||
cfg = spi_get_device_match_data(spi);
|
||||
if (!cfg)
|
||||
return -ENODATA;
|
||||
|
||||
ret = devm_regulator_bulk_get_enable(&spi->dev, ARRAY_SIZE(x9250_regulator_names),
|
||||
x9250_regulator_names);
|
||||
if (ret)
|
||||
|
|
@ -176,7 +181,7 @@ static int x9250_probe(struct spi_device *spi)
|
|||
|
||||
x9250 = iio_priv(indio_dev);
|
||||
x9250->spi = spi;
|
||||
x9250->cfg = spi_get_device_match_data(spi);
|
||||
x9250->cfg = cfg;
|
||||
x9250->wp_gpio = devm_gpiod_get_optional(&spi->dev, "wp", GPIOD_OUT_LOW);
|
||||
if (IS_ERR(x9250->wp_gpio))
|
||||
return dev_err_probe(&spi->dev, PTR_ERR(x9250->wp_gpio),
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user