Commit 0b3e9ab
sys: ring_buffer: fix possible ring_buf_put_claim/get_claim wrong size
- The issue is caused by the MIN() macro, which expands to
(a)<(b)?(a):(b), where ring_buf_space_get()/ring_buf_size_get()
is used as 'b' and is evaluated twice. The issue occurs when
the (a)<(b) condition evaluates such that (b) is selected,
but the value of (b) changes between evaluations, resulting
in a possibly larger value than (a).
- Fixes the potential incorrect behavior by storing the result
of ring_buf_space_get()/ring_buf_size_get() in a variable
before using it in the MIN macro.
Signed-off-by: Andrej Butok <[email protected]>1 parent 87ecedf commit 0b3e9ab
1 file changed
+4
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
| 307 | + | |
307 | 308 | | |
308 | | - | |
| 309 | + | |
309 | 310 | | |
310 | 311 | | |
311 | 312 | | |
| |||
385 | 386 | | |
386 | 387 | | |
387 | 388 | | |
| 389 | + | |
388 | 390 | | |
389 | | - | |
| 391 | + | |
390 | 392 | | |
391 | 393 | | |
392 | 394 | | |
| |||
0 commit comments