From: Bartosz Golaszewski Date: Sun, 4 Mar 2018 12:45:51 +0000 (+0100) Subject: gpio: mockup: fix a potential crash when creating debugfs entries X-Git-Tag: v4.17-rc1~121^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6cb9215baeb9c1ed336a5e8905f7ad7c4698acc9;p=thirdparty%2Fkernel%2Flinux.git gpio: mockup: fix a potential crash when creating debugfs entries If we failed to create the top debugfs directory, we must not try to create the child nodes. We currently only check if gpio_mockup_dbg_dir is not NULL, but it can also contain an errno if debugfs is disabled in build options. Use IS_ERR_OR_NULL() instead. Signed-off-by: Bartosz Golaszewski Signed-off-by: Linus Walleij --- diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index 21422b8e487bd..76c2fe91a901d 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -314,7 +314,7 @@ static int gpio_mockup_probe(struct platform_device *pdev) if (rv) return rv; - if (gpio_mockup_dbg_dir) + if (!IS_ERR_OR_NULL(gpio_mockup_dbg_dir)) gpio_mockup_debugfs_setup(dev, chip); return 0;