提交 2b0159d1 编写于 作者: S Sean Nyekjaer 提交者: Greg Kroah-Hartman

sc16is7xx: null ptr check

If a wrong compatible flag in specified, the of_match_device
returning null.
Implemented check and if NULL then returning -ENODEV.
Signed-off-by: NSean Nyekjaer <sean.nyekjaer@prevas.dk>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 adfb9233
......@@ -1321,6 +1321,9 @@ static int sc16is7xx_spi_probe(struct spi_device *spi)
const struct of_device_id *of_id =
of_match_device(sc16is7xx_dt_ids, &spi->dev);
if (!of_id)
return -ENODEV;
devtype = (struct sc16is7xx_devtype *)of_id->data;
} else {
const struct spi_device_id *id_entry = spi_get_device_id(spi);
......@@ -1380,6 +1383,9 @@ static int sc16is7xx_i2c_probe(struct i2c_client *i2c,
const struct of_device_id *of_id =
of_match_device(sc16is7xx_dt_ids, &i2c->dev);
if (!of_id)
return -ENODEV;
devtype = (struct sc16is7xx_devtype *)of_id->data;
} else {
devtype = (struct sc16is7xx_devtype *)id->driver_data;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册