Commit 69604fa
drivers: sensor: adxl355: fix is_fifo offset mismatch in decoder routing
adxl355_decoder_decode() reinterprets a raw sample buffer as
struct adxl355_fifo_data first, checking is_fifo at byte offset 0 to
decide whether to route to adxl355_decode_stream(). struct
adxl355_sample declared is_fifo last (after x/y/z/range), so offset 0
of a one-shot sample buffer was actually the low byte of x - real
accelerometer data, not a flag.
With CONFIG_ADXL355_STREAM=y, roughly half of all one-shot reads
(whenever bit 0 of the raw X LSB happened to be set) were misrouted
into adxl355_decode_stream(), which then reads fifo_byte_count and
sample_set_size at offsets 20-22 - past the 20-byte (sizeof(struct
adxl355_sample)) buffer - causing an out-of-bounds read.
Fix this by giving adxl355_sample an is_fifo field at offset 0,
matching adxl355_fifo_data's layout, and have adxl355_read_sample()
explicitly clear it rather than relying on zero-initialization.
Signed-off-by: Dimitrije Lilic <dimitrije.lilic@orioninc.com>1 parent 32f160c commit 69604fa
2 files changed
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
623 | 623 | | |
624 | 624 | | |
625 | 625 | | |
| 626 | + | |
626 | 627 | | |
627 | 628 | | |
628 | 629 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
| 272 | + | |
272 | 273 | | |
273 | 274 | | |
274 | 275 | | |
275 | 276 | | |
276 | | - | |
277 | 277 | | |
278 | 278 | | |
279 | 279 | | |
| |||
0 commit comments