Skip to content

Commit 3158211

Browse files
anthony289478cfriedt
authored andcommitted
sensor: icm45686: Use explicit VLA for fifo encoded data
The size of icm45686_encoded_data fifo_payload is guaranteed to span the full number of frames read as it was allocated during icm45686_event_handler() buf_len_required size. This update suppresses the static analysis warning of out of bounds memory access at index 1 by explicitly declaring fifo_payload to be a VLA at the end of icm45686_encoded_data. Signed-off-by: Anthony Williams <anthony289478@gmail.com>
1 parent d0d29aa commit 3158211

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

drivers/sensor/tdk/icm45686/icm45686.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ struct icm45686_encoded_data {
8282
struct icm45686_encoded_header header;
8383
union {
8484
struct icm45686_encoded_payload payload;
85-
struct icm45686_encoded_fifo_payload fifo_payload;
85+
FLEXIBLE_ARRAY_DECLARE(struct icm45686_encoded_fifo_payload, fifo_payload);
8686
};
8787
};
8888

drivers/sensor/tdk/icm45686/icm45686_decoder.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ static int icm45686_fifo_decode(const uint8_t *buffer,
476476
void *data_out)
477477
{
478478
struct icm45686_encoded_data *edata = (struct icm45686_encoded_data *)buffer;
479-
struct icm45686_encoded_fifo_payload *frame_begin = &edata->fifo_payload;
479+
struct icm45686_encoded_fifo_payload *frame_begin = edata->fifo_payload;
480480
int count = 0;
481481
int err;
482482

0 commit comments

Comments
 (0)