public inbox for linux-gpio@vger.kernel.org
 help / color / mirror / Atom feed
From: "Jonathan Neuschäfer" <j.neuschaefer@gmx.net>
To: Mikhail Kobuk <m.kobuk@ispras.ru>
Cc: "Jonathan Neuschäfer" <j.neuschaefer@gmx.net>,
	lvc-project@linuxtesting.org,
	"Linus Walleij" <linus.walleij@linaro.org>,
	linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
	openbmc@lists.ozlabs.org,
	"Alexey Khoroshilov" <khoroshilov@ispras.ru>
Subject: Re: [PATCH] pinctrl: nuvoton: wpcm450: fix out of bounds write
Date: Sun, 27 Aug 2023 20:46:18 +0200	[thread overview]
Message-ID: <ZOuZ+n3PZWqxsG35@probook> (raw)
In-Reply-To: <20230825101532.6624-1-m.kobuk@ispras.ru>

[-- Attachment #1: Type: text/plain, Size: 1391 bytes --]

On Fri, Aug 25, 2023 at 01:15:28PM +0300, Mikhail Kobuk wrote:
> Write into 'pctrl->gpio_bank' happens before the check for GPIO index
> validity, so out of bounds write may happen.

Good point.

Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>

Thanks!


> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: a1d1e0e3d80a ("pinctrl: nuvoton: Add driver for WPCM450")
> Signed-off-by: Mikhail Kobuk <m.kobuk@ispras.ru>
> Reviewed-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> ---
>  drivers/pinctrl/nuvoton/pinctrl-wpcm450.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
> index 2d1c1652cfd9..8a9961ac8712 100644
> --- a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
> +++ b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
> @@ -1062,13 +1062,13 @@ static int wpcm450_gpio_register(struct platform_device *pdev,
>  		if (ret < 0)
>  			return ret;
>  
> -		gpio = &pctrl->gpio_bank[reg];
> -		gpio->pctrl = pctrl;
> -
>  		if (reg >= WPCM450_NUM_BANKS)
>  			return dev_err_probe(dev, -EINVAL,
>  					     "GPIO index %d out of range!\n", reg);
>  
> +		gpio = &pctrl->gpio_bank[reg];
> +		gpio->pctrl = pctrl;
> +
>  		bank = &wpcm450_banks[reg];
>  		gpio->bank = bank;
>  
> -- 
> 2.42.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2023-08-27 18:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-25 10:15 [PATCH] pinctrl: nuvoton: wpcm450: fix out of bounds write Mikhail Kobuk
2023-08-27 18:46 ` Jonathan Neuschäfer [this message]
2023-09-12  7:04 ` Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZOuZ+n3PZWqxsG35@probook \
    --to=j.neuschaefer@gmx.net \
    --cc=khoroshilov@ispras.ru \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=m.kobuk@ispras.ru \
    --cc=openbmc@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox