Messages in this thread Patch in this message | | | From | Shailendra Verma <> | Subject | [PATCH] Gpio - Fix possible NULL derefrence. | Date | Fri, 27 Jan 2017 16:44:02 +0530 |
| |
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/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
| |