Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d76e8bab authored by Bartosz Golaszewski's avatar Bartosz Golaszewski Committed by Linus Walleij
Browse files

gpio: sta2x11: check the return value of irq_alloc_generic_chip()



This function can fail, so check the return value before dereferencing
the returned pointer.

Signed-off-by: default avatarBartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 09445a10
Loading
Loading
Loading
Loading
+10 −2
Original line number Original line Diff line number Diff line
@@ -320,13 +320,16 @@ static irqreturn_t gsta_gpio_handler(int irq, void *dev_id)
	return ret;
	return ret;
}
}


static void gsta_alloc_irq_chip(struct gsta_gpio *chip)
static int gsta_alloc_irq_chip(struct gsta_gpio *chip)
{
{
	struct irq_chip_generic *gc;
	struct irq_chip_generic *gc;
	struct irq_chip_type *ct;
	struct irq_chip_type *ct;


	gc = irq_alloc_generic_chip(KBUILD_MODNAME, 1, chip->irq_base,
	gc = irq_alloc_generic_chip(KBUILD_MODNAME, 1, chip->irq_base,
				     chip->reg_base, handle_simple_irq);
				     chip->reg_base, handle_simple_irq);
	if (!gc)
		return -ENOMEM;

	gc->private = chip;
	gc->private = chip;
	ct = gc->chip_types;
	ct = gc->chip_types;


@@ -350,6 +353,8 @@ static void gsta_alloc_irq_chip(struct gsta_gpio *chip)
		}
		}
		gc->irq_cnt = i - gc->irq_base;
		gc->irq_cnt = i - gc->irq_base;
	}
	}

	return 0;
}
}


/* The platform device used here is instantiated by the MFD device */
/* The platform device used here is instantiated by the MFD device */
@@ -400,7 +405,10 @@ static int gsta_probe(struct platform_device *dev)
		return err;
		return err;
	}
	}
	chip->irq_base = err;
	chip->irq_base = err;
	gsta_alloc_irq_chip(chip);

	err = gsta_alloc_irq_chip(chip);
	if (err)
		return err;


	err = devm_request_irq(&dev->dev, pdev->irq, gsta_gpio_handler,
	err = devm_request_irq(&dev->dev, pdev->irq, gsta_gpio_handler,
			       IRQF_SHARED, KBUILD_MODNAME, chip);
			       IRQF_SHARED, KBUILD_MODNAME, chip);