lkml.org 
[lkml]   [2017]   [Jan]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] Bus - Fix possible NULL derefrence.
Date
of_match_device could return NULL, and so can cause a NULL
pointer dereference later.

Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
---
drivers/bus/imx-weim.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/bus/imx-weim.c b/drivers/bus/imx-weim.c
index 4bd361d..5e26f44 100644
--- a/drivers/bus/imx-weim.c
+++ b/drivers/bus/imx-weim.c
@@ -138,12 +138,19 @@ static int __init weim_timing_setup(struct device_node *np, void __iomem *base,
static int __init weim_parse_dt(struct platform_device *pdev,
void __iomem *base)
{
- const struct of_device_id *of_id = of_match_device(weim_id_table,
- &pdev->dev);
- const struct imx_weim_devtype *devtype = of_id->data;
+ const struct of_device_id *of_id;
+ const struct imx_weim_devtype *devtype;
struct device_node *child;
int ret, have_child = 0;

+ of_id = of_match_device(weim_id_table, &pdev->dev);
+ if (!of_id) {
+ dev_err(&pdev->dev, "Error: No device match found\n");
+ return -ENODEV;
+ }
+
+ devtype = of_id->data;
+
if (devtype == &imx50_weim_devtype) {
ret = imx_weim_gpr_setup(pdev);
if (ret)
--
1.7.9.5
\
 
 \ /
  Last update: 2017-01-27 12:16    [W:0.026 / U:0.168 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site