lib: os: spsc_pbuf: Fix free space calculation

Fixing bug in free space calculation which was assuming 1 byte
padding and not 32 bit word padding. Bug could result in the
data corruption in certain scenario.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
Krzysztof Chruscinski 2022-07-27 09:51:10 +02:00 committed by Anas Nashif
commit 09b41829a8

View file

@ -184,7 +184,7 @@ int spsc_pbuf_alloc(struct spsc_pbuf *pb, uint16_t len, char **buf)
}
}
} else {
free_space = rd_idx - wr_idx - 1;
free_space = rd_idx - wr_idx - sizeof(uint32_t);
}
len = MIN(len, MAX(free_space - (int32_t)LEN_SZ, 0));