mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-30 00:00:16 +01:00
drivers: spi: avoid leaking uninitialized bits
Before this commit, line 84 read 'u' before it had a value, on 1st for-loop iteration. See comment on line 84 below: 82 for (n = 0; n < 8; n++) { 83 ctx->gpio->set(ctx->clk, inv); 84 u = (u << 1) | !!ctx->gpio->read(ctx->miso); /* <-- u is used uninitialized here */ 85 ctx->gpio->set(ctx->mosi, !!(u & 0x80)); 86 ctx->gpio->set(ctx->clk, !inv); 87 }
This commit is contained in:
parent
0a8f64ad5f
commit
2850de1afa
1 changed files with 2 additions and 1 deletions
|
@ -74,7 +74,8 @@ lws_bb_spi_write(lws_bb_spi_t *ctx, const uint8_t *buf, size_t len)
|
|||
static void
|
||||
lws_bb_spi_read(lws_bb_spi_t *ctx, uint8_t *buf, size_t len)
|
||||
{
|
||||
uint8_t u, inv = !!(ctx->bb_ops.bus_mode & LWSSPIMODE_CPOL);
|
||||
uint8_t u = 0;
|
||||
uint8_t inv = !!(ctx->bb_ops.bus_mode & LWSSPIMODE_CPOL);
|
||||
|
||||
while (len--) {
|
||||
int n;
|
||||
|
|
Loading…
Add table
Reference in a new issue