[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-id: <1485751953-29341-1-git-send-email-shailendra.v@samsung.com>
Date: Mon, 30 Jan 2017 10:22:33 +0530
From: Shailendra Verma <shailendra.v@...sung.com>
To: Thierry Reding <thierry.reding@...il.com>,
Maxime Ripard <maxime.ripard@...e-electrons.com>,
Chen-Yu Tsai <wens@...e.org>,
Stephen Warren <swarren@...dotorg.org>,
Alexandre Courbot <gnurou@...il.com>,
linux-pwm@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-tegra@...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] pwm - 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/pwm/pwm-sun4i.c | 4 ++++
drivers/pwm/pwm-tegra.c | 5 +++++
2 files changed, 9 insertions(+)
diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c
index b0803f6..9b5c6fe 100644
--- a/drivers/pwm/pwm-sun4i.c
+++ b/drivers/pwm/pwm-sun4i.c
@@ -321,6 +321,10 @@ static int sun4i_pwm_probe(struct platform_device *pdev)
const struct of_device_id *match;
match = of_match_device(sun4i_pwm_dt_ids, &pdev->dev);
+ if (!match) {
+ dev_err(&pdev->dev, "Error: No device match found\n");
+ return -ENODEV;
+ }
pwm = devm_kzalloc(&pdev->dev, sizeof(*pwm), GFP_KERNEL);
if (!pwm)
diff --git a/drivers/pwm/pwm-tegra.c b/drivers/pwm/pwm-tegra.c
index e464784..a5eb224 100644
--- a/drivers/pwm/pwm-tegra.c
+++ b/drivers/pwm/pwm-tegra.c
@@ -185,6 +185,11 @@ static int tegra_pwm_probe(struct platform_device *pdev)
return -ENOMEM;
pwm->soc = of_device_get_match_data(&pdev->dev);
+ if (!pwm->soc) {
+ dev_err(&pdev->dev, "no device match found\n");
+ return -ENODEV;
+ }
+
pwm->dev = &pdev->dev;
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
--
1.7.9.5
Powered by blists - more mailing lists