public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
Cc: stable@vger.kernel.org, sashal@kernel.org,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Mark Brown <broonie@kernel.org>
Subject: Re: [PATCH for 5.10.y] spi: Switch to signed types for *_native_cs SPI controller fields
Date: Mon, 6 Sep 2021 10:47:09 +0200	[thread overview]
Message-ID: <YTXVjcc6D2oSZ0LA@kroah.com> (raw)
In-Reply-To: <20210906060842.2913612-1-nobuhiro1.iwamatsu@toshiba.co.jp>

On Mon, Sep 06, 2021 at 03:08:42PM +0900, Nobuhiro Iwamatsu wrote:
> From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> commit 35f3f8504c3b60a1ae5576e178b27fc0ddd6157d upstream.
> 
> While fixing undefined behaviour the commit f60d7270c8a3 ("spi: Avoid
> undefined behaviour when counting unused native CSs") missed the case
> when all CSs are GPIOs and thus unused_native_cs will be evaluated to
> -1 in unsigned representation. This will falsely trigger a condition
> in the spi_get_gpio_descs().
> 
> Switch to signed types for *_native_cs SPI controller fields to fix above.
> 
> Fixes: f60d7270c8a3 ("spi: Avoid undefined behaviour when counting unused native CSs")
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Link: https://lore.kernel.org/r/20210510131242.49455-1-andriy.shevchenko@linux.intel.com
> Signed-off-by: Mark Brown <broonie@kernel.org>
> Signed-off-by: Nobuhiro Iwamatsu (CIP) <nobuhiro1.iwamatsu@toshiba.co.jp>
> ---
>  include/linux/spi/spi.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
> index 2d906b9c149929..e1d88630ff2439 100644
> --- a/include/linux/spi/spi.h
> +++ b/include/linux/spi/spi.h
> @@ -646,8 +646,8 @@ struct spi_controller {
>  	int			*cs_gpios;
>  	struct gpio_desc	**cs_gpiods;
>  	bool			use_gpio_descriptors;
> -	u8			unused_native_cs;
> -	u8			max_native_cs;
> +	s8			unused_native_cs;
> +	s8			max_native_cs;
>  
>  	/* statistics */
>  	struct spi_statistics	statistics;
> -- 
> 2.33.0
> 
> 

Now queued up, thanks.

greg k-h

      reply	other threads:[~2021-09-06  8:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-06  6:08 [PATCH for 5.10.y] spi: Switch to signed types for *_native_cs SPI controller fields Nobuhiro Iwamatsu
2021-09-06  8:47 ` Greg KH [this message]

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=YTXVjcc6D2oSZ0LA@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=nobuhiro1.iwamatsu@toshiba.co.jp \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.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