diff options
author | Quentin Schulz <quentin.schulz@free-electrons.com> | 2017-12-13 03:55:03 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2017-12-20 03:06:29 -0500 |
commit | a049815229b6fcf0dd927630cbf5c127f5fb2a82 (patch) | |
tree | 1cad5808446c50beb50e4fc2813f4d44d71c7368 /drivers/pinctrl/pinctrl-axp209.c | |
parent | 5c9d8c4f6b8168738a26bcf288516cc3a0886810 (diff) |
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: e1190083b89b ("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>
Diffstat (limited to 'drivers/pinctrl/pinctrl-axp209.c')
-rw-r--r-- | drivers/pinctrl/pinctrl-axp209.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c index 22d3bb0bf927..510a2821e910 100644 --- a/drivers/pinctrl/pinctrl-axp209.c +++ b/drivers/pinctrl/pinctrl-axp209.c | |||
@@ -413,9 +413,11 @@ static int axp20x_pctl_probe(struct platform_device *pdev) | |||
413 | pctl->chip.set = axp20x_gpio_set; | 413 | pctl->chip.set = axp20x_gpio_set; |
414 | pctl->chip.direction_input = axp20x_gpio_input; | 414 | pctl->chip.direction_input = axp20x_gpio_input; |
415 | pctl->chip.direction_output = axp20x_gpio_output; | 415 | pctl->chip.direction_output = axp20x_gpio_output; |
416 | pctl->chip.ngpio = pctl->desc->npins; | ||
417 | 416 | ||
418 | pctl->desc = (struct axp20x_pctrl_desc *)of_device_get_match_data(dev); | 417 | pctl->desc = (struct axp20x_pctrl_desc *)of_device_get_match_data(dev); |
418 | |||
419 | pctl->chip.ngpio = pctl->desc->npins; | ||
420 | |||
419 | pctl->regmap = axp20x->regmap; | 421 | pctl->regmap = axp20x->regmap; |
420 | pctl->dev = &pdev->dev; | 422 | pctl->dev = &pdev->dev; |
421 | 423 | ||