Skip to content

Commit ded9137

Browse files
andy-shevgregkh
authored andcommitted
spi: Switch to signed types for *_native_cs SPI controller fields
commit 35f3f85 upstream. While fixing undefined behaviour the commit f60d727 ("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: f60d727 ("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 55bb519 commit ded9137

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎include/linux/spi/spi.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,8 +646,8 @@ struct spi_controller {
646646
int *cs_gpios;
647647
struct gpio_desc **cs_gpiods;
648648
bool use_gpio_descriptors;
649-
u8 unused_native_cs;
650-
u8 max_native_cs;
649+
s8 unused_native_cs;
650+
s8 max_native_cs;
651651

652652
/* statistics */
653653
struct spi_statistics statistics;

0 commit comments

Comments
 (0)