pinctrl: axp209: dereference pointer after it's been set

The number of GPIOs is gotten from a field within the structure
referenced in the of_device.data but it was actually read before it was
retrieved, thus it was dereferencing a null pointer.

Set the number of GPIOs after retrieving of_device.data.

Fixes: e1190083b8 ("pinctrl: axp209: add support for AXP813 GPIOs")
Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Reported-by: Mylène Josserand <mylene.josserand@free-electrons.com>
Tested-by: Mylène Josserand <mylene.josserand@free-electrons.com>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
Quentin Schulz 2017-12-13 09:55:03 +01:00 committed by Linus Walleij
parent 5c9d8c4f6b
commit a049815229
1 changed files with 3 additions and 1 deletions

View File

@ -413,9 +413,11 @@ static int axp20x_pctl_probe(struct platform_device *pdev)
pctl->chip.set = axp20x_gpio_set;
pctl->chip.direction_input = axp20x_gpio_input;
pctl->chip.direction_output = axp20x_gpio_output;
pctl->chip.ngpio = pctl->desc->npins;
pctl->desc = (struct axp20x_pctrl_desc *)of_device_get_match_data(dev);
pctl->chip.ngpio = pctl->desc->npins;
pctl->regmap = axp20x->regmap;
pctl->dev = &pdev->dev;