diff options
author | Sean Nyekjaer <sean.nyekjaer@prevas.dk> | 2015-10-04 19:59:45 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-10-04 21:14:26 +0300 |
commit | 2b0159d1ecfbc11badb96466c0c1582ee5ffe78f (patch) | |
tree | 4b927dd4e443947073e3b958803d1694db261b1f /drivers/tty/serial/sc16is7xx.c | |
parent | adfb9233e434896e87811339ca0c18bc923b262f (diff) | |
download | linux-2b0159d1ecfbc11badb96466c0c1582ee5ffe78f.tar.xz |
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: Sean Nyekjaer <sean.nyekjaer@prevas.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/sc16is7xx.c')
-rw-r--r-- | drivers/tty/serial/sc16is7xx.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index c4abd7557b35..1ae8aa698fcb 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -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; |