[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-id: <1485751903-29284-1-git-send-email-shailendra.v@samsung.com>
Date: Mon, 30 Jan 2017 10:21:43 +0530
From: Shailendra Verma <shailendra.v@...sung.com>
To: Linus Walleij <linus.walleij@...aro.org>,
Laxman Dewangan <ldewangan@...dia.com>,
Thomas Petazzoni <thomas.petazzoni@...e-electrons.com>,
Andreas Klinger <ak@...klinger.de>,
Sebastian Hesselbarth <sebastian.hesselbarth@...il.com>,
Andrew Lunn <andrew@...n.ch>, Jamie Lentin <jm@...tin.co.uk>,
Rob Herring <robh@...nel.org>, linux-gpio@...r.kernel.org,
linux-kernel@...r.kernel.org, p.shailesh@...sung.com,
ashish.kalra@...sung.com,
Shailendra Verma <shailendra.v@...sung.com>,
Shailendra Verma <shailendra.capricorn@...il.com>
Subject: [PATCH] Pinctrl: mvebu - Fix possible NULL derefrence.
of_match_device could return NULL, and so can cause a NULL
pointer dereference later.
Signed-off-by: Shailendra Verma <shailendra.v@...sung.com>
---
drivers/pinctrl/mvebu/pinctrl-dove.c | 4 ++++
drivers/pinctrl/mvebu/pinctrl-kirkwood.c | 4 ++++
drivers/pinctrl/mvebu/pinctrl-orion.c | 4 ++++
3 files changed, 12 insertions(+)
diff --git a/drivers/pinctrl/mvebu/pinctrl-dove.c b/drivers/pinctrl/mvebu/pinctrl-dove.c
index f93ae0d..f9fe6d4 100644
--- a/drivers/pinctrl/mvebu/pinctrl-dove.c
+++ b/drivers/pinctrl/mvebu/pinctrl-dove.c
@@ -769,6 +769,10 @@ static int dove_pinctrl_probe(struct platform_device *pdev)
struct resource fb_res;
const struct of_device_id *match =
of_match_device(dove_pinctrl_of_match, &pdev->dev);
+ if (!match) {
+ dev_err(&pdev->dev, "Error: No device match found\n");
+ return -ENODEV;
+ }
pdev->dev.platform_data = (void *)match->data;
/*
diff --git a/drivers/pinctrl/mvebu/pinctrl-kirkwood.c b/drivers/pinctrl/mvebu/pinctrl-kirkwood.c
index 5f89c26..75efb83 100644
--- a/drivers/pinctrl/mvebu/pinctrl-kirkwood.c
+++ b/drivers/pinctrl/mvebu/pinctrl-kirkwood.c
@@ -472,6 +472,10 @@ static int kirkwood_pinctrl_probe(struct platform_device *pdev)
struct resource *res;
const struct of_device_id *match =
of_match_device(kirkwood_pinctrl_of_match, &pdev->dev);
+ if (!match) {
+ dev_err(&pdev->dev, "Error: No device match found\n");
+ return -ENODEV;
+ }
pdev->dev.platform_data = (void *)match->data;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
diff --git a/drivers/pinctrl/mvebu/pinctrl-orion.c b/drivers/pinctrl/mvebu/pinctrl-orion.c
index 84e1441..559ac32 100644
--- a/drivers/pinctrl/mvebu/pinctrl-orion.c
+++ b/drivers/pinctrl/mvebu/pinctrl-orion.c
@@ -225,6 +225,10 @@ static int orion_pinctrl_probe(struct platform_device *pdev)
of_match_device(orion_pinctrl_of_match, &pdev->dev);
struct resource *res;
+ if (!match) {
+ dev_err(&pdev->dev, "Error: No device match found\n");
+ return -ENODEV;
+ }
pdev->dev.platform_data = (void*)match->data;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
--
1.7.9.5
Powered by blists - more mailing lists