Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

spi: stm32-qspi: Fix stm32_qspi_transfer_one_message() error path

The patch a557fca630cc: "spi: stm32_qspi: Add transfer_one_message()
spi callback" from Aug 23, 2022, leads to the following Smatch static
checker warning:

drivers/spi/spi-stm32-qspi.c:627 stm32_qspi_transfer_one_message()
error: uninitialized symbol 'ret'.Fix the following Smatch static checker warning:

Fixes: a557fca630cc ("spi: stm32_qspi: Add transfer_one_message() spi callback")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Link: https://lore.kernel.org/r/20220826092031.1393430-1-patrice.chotard@foss.st.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Patrice Chotard and committed by
Mark Brown
56ec4562 3fe26121

+4 -2
+4 -2
drivers/spi/spi-stm32-qspi.c
··· 562 562 struct spi_transfer *transfer; 563 563 struct spi_device *spi = msg->spi; 564 564 struct spi_mem_op op; 565 - int ret; 565 + int ret = 0; 566 566 567 567 if (!spi->cs_gpiod) 568 568 return -EOPNOTSUPP; ··· 592 592 dummy_bytes = transfer->len; 593 593 594 594 /* if happens, means that message is not correctly built */ 595 - if (list_is_last(&transfer->transfer_list, &msg->transfers)) 595 + if (list_is_last(&transfer->transfer_list, &msg->transfers)) { 596 + ret = -EINVAL; 596 597 goto end_of_transfer; 598 + } 597 599 598 600 transfer = list_next_entry(transfer, transfer_list); 599 601 }