spi: stm32: fix spi_stm32_init()

It is incorrect to call spi_context_release() on an STM32
spi_stm32_data object's ctx field before data->ctx->config is first
set in spi_stm32_configure(). This is because spi_context_release()
reads ctx->config->operation. In particular, during spi_stm32_init(),
calling spi_context_release() reads the uninitialized memory in
data->ctx->config->operation.

Call spi_context_unlock_unconditionally() instead to properly increase
the semaphore count.

Without this patch, the first call to spi_transceive() can block
forever depending on the value of the uninitialized memory holding
data->ctx->config->operation.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
This commit is contained in:
Marti Bolivar 2017-07-13 18:31:44 -04:00 committed by Anas Nashif
commit 6318750837

View file

@ -351,7 +351,7 @@ static int spi_stm32_init(struct device *dev)
cfg->irq_config(dev);
#endif
spi_context_release(&data->ctx, 0);
spi_context_unlock_unconditionally(&data->ctx);
return 0;
}