gpio: mockup: fix a potential crash when creating debugfs entries
authorBartosz Golaszewski <brgl@bgdev.pl>
Sun, 4 Mar 2018 12:45:51 +0000 (13:45 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Tue, 27 Mar 2018 13:18:20 +0000 (15:18 +0200)
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 <brgl@bgdev.pl>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-mockup.c

index 21422b8e487bd7f01bb99cb35271843383a64cf7..76c2fe91a901dcd1f9b4154e3e31858a9f5e2a9a 100644 (file)
@@ -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;