diff options
author | Axel Lin <axel.lin@ingics.com> | 2016-03-21 08:03:50 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2016-03-30 04:39:39 -0400 |
commit | 8d8ee18cc707f498b6dad18915576f23b00bcff8 (patch) | |
tree | bb2862066c6a7494e3e1b22d56961db3cf740f0b | |
parent | fd975a7b180c9a8f6e02d2251eaabe9b0dcfeed6 (diff) |
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 <axel.lin@ingics.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/gpio/gpio-xgene.c | 5 |
1 files changed, 5 insertions, 0 deletions
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) | |||
173 | } | 173 | } |
174 | 174 | ||
175 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 175 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
176 | if (!res) { | ||
177 | err = -EINVAL; | ||
178 | goto err; | ||
179 | } | ||
180 | |||
176 | gpio->base = devm_ioremap_nocache(&pdev->dev, res->start, | 181 | gpio->base = devm_ioremap_nocache(&pdev->dev, res->start, |
177 | resource_size(res)); | 182 | resource_size(res)); |
178 | if (!gpio->base) { | 183 | if (!gpio->base) { |