Sfoglia il codice sorgente

gpio: palmas: fix a possible NULL dereference

of_match_device could return NULL, and so cause a NULL pointer
dereference later.

Reported-by: coverity (CID 1130700)
Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
LABBE Corentin 9 anni fa
parent
commit
5664de25fa
1 ha cambiato i file con 2 aggiunte e 0 eliminazioni
  1. 2 0
      drivers/gpio/gpio-palmas.c

+ 2 - 0
drivers/gpio/gpio-palmas.c

@@ -167,6 +167,8 @@ static int palmas_gpio_probe(struct platform_device *pdev)
 	const struct palmas_device_data *dev_data;
 
 	match = of_match_device(of_palmas_gpio_match, &pdev->dev);
+	if (!match)
+		return -ENODEV;
 	dev_data = match->data;
 	if (!dev_data)
 		dev_data = &palmas_dev_data;