From 8d8ee18cc707f498b6dad18915576f23b00bcff8 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Mon, 21 Mar 2016 20:03:50 +0800 Subject: gpio: xgene: Prevent NULL pointer dereference platform_get_resource() can return NULL, thus add NULL test to prevent NULL pointer dereference. Signed-off-by: Axel Lin Signed-off-by: Linus Walleij --- drivers/gpio/gpio-xgene.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers') diff --git a/drivers/gpio/gpio-xgene.c b/drivers/gpio/gpio-xgene.c index c0aa387664bf..0dc916191689 100644 --- a/drivers/gpio/gpio-xgene.c +++ b/drivers/gpio/gpio-xgene.c @@ -173,6 +173,11 @@ static int xgene_gpio_probe(struct platform_device *pdev) } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + err = -EINVAL; + goto err; + } + gpio->base = devm_ioremap_nocache(&pdev->dev, res->start, resource_size(res)); if (!gpio->base) { -- cgit v1.2.3