summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAditya Pakki <pakki001@umn.edu>2019-03-18 18:44:14 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-04-03 06:26:25 +0200
commitf34ec64b3f6cc2ae83da6901430be0204297f2d4 (patch)
tree3c2a1f482dbfcf221c1dcaf0b45433da5140f3fb
parenta090ed15420abf719ba077e9f60defbb1f636831 (diff)
downloadlinux-rpi3-f34ec64b3f6cc2ae83da6901430be0204297f2d4.tar.gz
linux-rpi3-f34ec64b3f6cc2ae83da6901430be0204297f2d4.tar.bz2
linux-rpi3-f34ec64b3f6cc2ae83da6901430be0204297f2d4.zip
serial: max310x: Fix to avoid potential NULL pointer dereference
commit 3a10e3dd52e80b9a97a3346020024d17b2c272d6 upstream. of_match_device can return a NULL pointer when matching device is not found. This patch avoids a scenario causing NULL pointer derefernce. Signed-off-by: Aditya Pakki <pakki001@umn.edu> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/serial/max310x.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
index 3db48fcd6068..4c4070a202fb 100644
--- a/drivers/tty/serial/max310x.c
+++ b/drivers/tty/serial/max310x.c
@@ -1419,6 +1419,8 @@ static int max310x_spi_probe(struct spi_device *spi)
if (spi->dev.of_node) {
const struct of_device_id *of_id =
of_match_device(max310x_dt_ids, &spi->dev);
+ if (!of_id)
+ return -ENODEV;
devtype = (struct max310x_devtype *)of_id->data;
} else {