Skip to content

Commit 09b4182

Browse files
nordic-krchnashif
authored andcommitted
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 <[email protected]>
1 parent a0a8a12 commit 09b4182

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/os/spsc_pbuf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ int spsc_pbuf_alloc(struct spsc_pbuf *pb, uint16_t len, char **buf)
184184
}
185185
}
186186
} else {
187-
free_space = rd_idx - wr_idx - 1;
187+
free_space = rd_idx - wr_idx - sizeof(uint32_t);
188188
}
189189

190190
len = MIN(len, MAX(free_space - (int32_t)LEN_SZ, 0));

0 commit comments

Comments
 (0)