qcom: ssbi-gpio: correct boundary conditions in pm8xxx_domain_translate
authorBrian Masney <masneyb@onstation.org>
Thu, 14 Feb 2019 01:36:41 +0000 (20:36 -0500)
committerLinus Walleij <linus.walleij@linaro.org>
Thu, 14 Feb 2019 09:03:04 +0000 (10:03 +0100)
SSBI GPIOs are numbered 1..ngpio, so the boundary check in
pm8xxx_domain_translate() is off by one. This patch corrects that check.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c

index 84a232450000da8a23e837bb70c08455caa2735b..08dd62b5cebec1a04170d9e07486eb9da2a2797d 100644 (file)
@@ -710,7 +710,8 @@ static int pm8xxx_domain_translate(struct irq_domain *domain,
        struct pm8xxx_gpio *pctrl = container_of(domain->host_data,
                                                 struct pm8xxx_gpio, chip);
 
-       if (fwspec->param_count != 2 || fwspec->param[0] >= pctrl->chip.ngpio)
+       if (fwspec->param_count != 2 || fwspec->param[0] < 1 ||
+           fwspec->param[0] > pctrl->chip.ngpio)
                return -EINVAL;
 
        *hwirq = fwspec->param[0] - PM8XXX_GPIO_PHYSICAL_OFFSET;