[3/3] gpio: palmas: fix a possible NULL dereference
diff mbox

Message ID 1447273657-1668-3-git-send-email-clabbe.montjoie@gmail.com
State New
Headers show

Commit Message

Corentin Labbe Nov. 11, 2015, 8:27 p.m. UTC
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>
---
 drivers/gpio/gpio-palmas.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Linus Walleij Nov. 17, 2015, 1:41 p.m. UTC | #1
On Wed, Nov 11, 2015 at 9:27 PM, LABBE Corentin
<clabbe.montjoie@gmail.com> wrote:

> 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>

Patch applied.

ALl of these seem pretty academic, as the match table is likely
the same that causes the device core to call probe() in the
first place. But whatever.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/drivers/gpio/gpio-palmas.c b/drivers/gpio/gpio-palmas.c
index 171a638..52b447c 100644
--- a/drivers/gpio/gpio-palmas.c
+++ b/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;