[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6529745.9OfISSL0U5@diego>
Date: Sun, 06 Sep 2020 00:14:12 +0200
From: Heiko Stübner <heiko@...ech.de>
To: linus.walleij@...aro.org, Jianqun Xu <jay.xu@...k-chips.com>
Cc: linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-rockchip@...ts.infradead.org,
Jianqun Xu <jay.xu@...k-chips.com>
Subject: Re: [PATCH 5/6] pinctrl: rockchip: fix crash caused by invalid gpio bank
Hi,
Am Montag, 31. August 2020, 10:50:10 CEST schrieb Jianqun Xu:
> Add valid check for gpio bank.
Please add more description on where this happened.
> Change-Id: Ia4609c3045b5df7879beab3c15d791ff54a1f49b
Please drop the change-id.
> Signed-off-by: Jianqun Xu <jay.xu@...k-chips.com>
> ---
> drivers/pinctrl/pinctrl-rockchip.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
> index 6080573155f6..5b16b69e311f 100644
> --- a/drivers/pinctrl/pinctrl-rockchip.c
> +++ b/drivers/pinctrl/pinctrl-rockchip.c
> @@ -2526,9 +2526,9 @@ static int rockchip_pmx_set(struct pinctrl_dev *pctldev, unsigned selector,
> break;
> }
>
> - if (ret) {
> + if (ret && cnt) {
> /* revert the already done pin settings */
> - for (cnt--; cnt >= 0; cnt--)
> + for (cnt--; cnt >= 0 && !data[cnt].func; cnt--)
This looks unrelated and as it's not a "check for a valid gpio-bank" it
should become a separate patch with a commit message describing it nicely.
> rockchip_set_mux(bank, pins[cnt] - bank->pin_base, 0);
>
> return ret;
> @@ -2599,9 +2599,13 @@ static int rockchip_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
> unsigned offset, bool input)
> {
> struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
> + struct rockchip_pin_bank *bank = &info->ctrl->pin_banks[offset / 32];
> struct gpio_chip *chip;
> int pin;
>
> + if (!bank || !bank->valid)
> + return 0;
> +
> chip = range->gc;
> pin = offset - chip->base;
> dev_dbg(info->dev, "gpio_direction for pin %u as %s-%d to %s\n",
> @@ -3022,6 +3026,8 @@ static int rockchip_pinctrl_register(struct platform_device *pdev,
>
> for (bank = 0; bank < info->ctrl->nr_banks; ++bank) {
> pin_bank = &info->ctrl->pin_banks[bank];
> + if (!pin_bank->valid)
> + continue;
Please add a blank line here
> pin_bank->grange.name = pin_bank->name;
> pin_bank->grange.id = bank;
> pin_bank->grange.pin_base = pin_bank->pin_base;
>
Thanks
Heiko
Powered by blists - more mailing lists