Skip to content

Commit

Permalink
gpio: generic: improve error handling in bgpio_map
Browse files Browse the repository at this point in the history
If bgpio_map returns NULL then err should always be set.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Heiner Kallweit authored and Linus Walleij committed Oct 5, 2015
1 parent 2db8aba commit cf3f2a2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/gpio/gpio-generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,10 @@ static void __iomem *bgpio_map(struct platform_device *pdev,
*err = 0;

r = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
if (!r)
if (!r) {
*err = -EINVAL;
return NULL;
}

sz = resource_size(r);
if (sz != sane_sz) {
Expand Down Expand Up @@ -637,8 +639,8 @@ static int bgpio_pdev_probe(struct platform_device *pdev)
sz = resource_size(r);

dat = bgpio_map(pdev, "dat", sz, &err);
if (!dat)
return err ? err : -EINVAL;
if (err)
return err;

set = bgpio_map(pdev, "set", sz, &err);
if (err)
Expand Down

0 comments on commit cf3f2a2

Please sign in to comment.