[1/3] gpio: generic: improve error handling in bgpio_map
diff mbox

Message ID 560C591C.2030709@gmail.com
State New
Headers show

Commit Message

Heiner Kallweit Sept. 30, 2015, 9:50 p.m. UTC
If bgpio_map returns NULL then err should always be set.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/gpio/gpio-generic.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Linus Walleij Oct. 5, 2015, 7:14 a.m. UTC | #1
On Wed, Sep 30, 2015 at 11:50 PM, Heiner Kallweit <hkallweit1@gmail.com> wrote:

> If bgpio_map returns NULL then err should always be set.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>

Looks correct. Patch applied.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c
index a3f0753..eefff1a 100644
--- a/drivers/gpio/gpio-generic.c
+++ b/drivers/gpio/gpio-generic.c
@@ -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) {
@@ -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)