pinctrl: msm: Check for ngpios > MAX_NR_GPIO
authorStephen Boyd <sboyd@codeaurora.org>
Fri, 7 Mar 2014 06:44:41 +0000 (22:44 -0800)
committerLinus Walleij <linus.walleij@linaro.org>
Wed, 12 Mar 2014 14:12:27 +0000 (15:12 +0100)
Fail the probe and print a warning if SoC specific drivers have
more GPIOs than there can be accounted for in the static bitmaps.
This should avoid silent corruption/failures in the future.

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Acked-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/pinctrl-msm.c

index 2df3a48974f3feeb47b15bcb9327d0478408dd78..e563bbc5cefc7ee9e00fd117ae3dd8c544e3edf5 100644 (file)
@@ -897,10 +897,14 @@ static int msm_gpio_init(struct msm_pinctrl *pctrl)
        int ret;
        int i;
        int r;
+       unsigned ngpio = pctrl->soc->ngpios;
+
+       if (WARN_ON(ngpio > MAX_NR_GPIO))
+               return -EINVAL;
 
        chip = &pctrl->chip;
        chip->base = 0;
-       chip->ngpio = pctrl->soc->ngpios;
+       chip->ngpio = ngpio;
        chip->label = dev_name(pctrl->dev);
        chip->dev = pctrl->dev;
        chip->owner = THIS_MODULE;