@@ -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;
@@ -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;
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(+)