[PATCH v2025.09.y 43/58] mci: spi: initialize r1 to fix garbage return value
Ahmad Fatoum
a.fatoum at pengutronix.de
Fri Mar 13 06:25:27 PDT 2026
If bcnt is 0, the while loop body never executes and r1 is returned
uninitialized. Initialize it to 0 (success) which is the correct
result when there are no blocks to write.
(cherry picked from commit 095bd13cf981aaceb4c0f5f7e9b14a3482c3be7e)
Reported-by: GCC 14.2 -fanalyzer
Co-Authored-By: Claude Opus 4.6 <noreply at anthropic.com>
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
Link: https://lore.barebox.org/20260216084253.3547270-12-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
drivers/mci/mci_spi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mci/mci_spi.c b/drivers/mci/mci_spi.c
index 3ab90d768fbd..b495cdaafcf4 100644
--- a/drivers/mci/mci_spi.c
+++ b/drivers/mci/mci_spi.c
@@ -172,7 +172,7 @@ static uint mmc_spi_writedata(struct mmc_spi_host *host, const void *xbuf,
uint32_t bcnt, uint32_t bsize, int multi)
{
const uint8_t *buf = xbuf;
- uint8_t r1;
+ uint8_t r1 = 0;
uint16_t crc = 0;
uint8_t tok[2];
int i;
--
2.47.3
More information about the barebox
mailing list