[<prev] [next>] [day] [month] [year] [list]
Message-id: <1485515642-3310-1-git-send-email-shailendra.v@samsung.com>
Date: Fri, 27 Jan 2017 16:44:02 +0530
From: Shailendra Verma <shailendra.v@...sung.com>
To: Linus Walleij <linus.walleij@...aro.org>,
Alexandre Courbot <gnurou@...il.com>,
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] Gpio - 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/gpio/gpio-ge.c | 5 +++++
drivers/gpio/gpio-mxs.c | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/drivers/gpio/gpio-ge.c b/drivers/gpio/gpio-ge.c
index 8650b29..395a85d 100644
--- a/drivers/gpio/gpio-ge.c
+++ b/drivers/gpio/gpio-ge.c
@@ -59,6 +59,11 @@ static int __init gef_gpio_probe(struct platform_device *pdev)
void __iomem *regs;
int ret;
+ if (!of_id) {
+ dev_err(&pdev->dev, "Error: No device match found\n");
+ return -ENODEV;
+ }
+
gc = devm_kzalloc(&pdev->dev, sizeof(*gc), GFP_KERNEL);
if (!gc)
return -ENOMEM;
diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c
index ee17248..e28097f 100644
--- a/drivers/gpio/gpio-mxs.c
+++ b/drivers/gpio/gpio-mxs.c
@@ -272,6 +272,11 @@ static int mxs_gpio_probe(struct platform_device *pdev)
int irq_base;
int err;
+ if (!of_id) {
+ dev_err(&pdev->dev, "Error: No device match found\n");
+ return -ENODEV;
+ }
+
port = devm_kzalloc(&pdev->dev, sizeof(*port), GFP_KERNEL);
if (!port)
return -ENOMEM;
--
1.7.9.5
Powered by blists - more mailing lists