From 3db04ea17455c01b8a0fde9135bd6e88480d1972 Mon Sep 17 00:00:00 2001 From: lilvinz Date: Sun, 28 Oct 2012 14:34:20 +0100 Subject: [PATCH] pios_jedec: fixed usage of uninitialized memory When reading the jedec device id the code only transfered one byte via spi leaving the expected input buffer uninitialized. This may lead to the problem that flash initialization fails because the expected input may be whatever the stack was set when entering the function. The impact of the bug is somewhat limited tough as the initialization usually takes place before starting up the rtos and thus is pretty deterministic. So if the code passed init while testing it should pass init in production as well. --- flight/PiOS/Common/pios_flash_jedec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flight/PiOS/Common/pios_flash_jedec.c b/flight/PiOS/Common/pios_flash_jedec.c index ed4a6390b..e40b0b7dc 100644 --- a/flight/PiOS/Common/pios_flash_jedec.c +++ b/flight/PiOS/Common/pios_flash_jedec.c @@ -249,7 +249,7 @@ int32_t PIOS_Flash_Jedec_ReadStatus() */ int32_t PIOS_Flash_Jedec_ReadID() { - uint8_t out[] = {JEDEC_DEVICE_ID}; + uint8_t out[] = {JEDEC_DEVICE_ID, 0, 0, 0}; uint8_t in[4]; if (PIOS_Flash_Jedec_ClaimBus() < 0) return -1;