You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ut...@apache.org on 2019/05/06 11:09:21 UTC

[mynewt-core] branch master updated: [STM32] SPI - fix usage of unitialized variable

This is an automated email from the ASF dual-hosted git repository.

utzig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new e48eb56  [STM32] SPI - fix usage of unitialized variable
e48eb56 is described below

commit e48eb56604b8702f5b77eff086648eea78f97242
Author: Fabio Utzig <ut...@apache.org>
AuthorDate: Mon May 6 07:08:02 2019 -0300

    [STM32] SPI - fix usage of unitialized variable
    
    When doing an 8-byte SPI transfer the high byte of the uint16_t return
    variable was never initialized and could return to the caller whatever
    was on the stack. This initializes the variable before doing the SPI
    transfer.
---
 hw/mcu/stm/stm32_common/src/hal_spi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/mcu/stm/stm32_common/src/hal_spi.c b/hw/mcu/stm/stm32_common/src/hal_spi.c
index a547f0d..e8abbda 100644
--- a/hw/mcu/stm/stm32_common/src/hal_spi.c
+++ b/hw/mcu/stm/stm32_common/src/hal_spi.c
@@ -926,6 +926,7 @@ uint16_t hal_spi_tx_val(int spi_num, uint16_t val)
     }
     __HAL_DISABLE_INTERRUPTS(sr);
     spi_stat.tx++;
+    retval = 0;
     rc = HAL_SPI_TransmitReceive(&spi->handle,(uint8_t *)&val,
                                  (uint8_t *)&retval, len,
                                  STM32_HAL_SPI_TIMEOUT);