ipc3: move pointer assignments to after validation

UBSAN is complaining about the pointers being overflown given we haven't
checked the parameters. Move it behind the code that protects this to
satisfy the sanitizer.

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
This commit is contained in:
Curtis Malainey 2024-09-03 16:27:30 -07:00 committed by Kai Vehmanen
parent 53adb48cfa
commit 54bb3e4d01
1 changed files with 3 additions and 2 deletions

View File

@ -904,8 +904,6 @@ static int ipc_trace_filter_update(uint32_t header)
int cnt;
packet = ipc->comp_data;
elem = packet->elems;
end = &packet->elems[packet->elem_cnt];
/* validation, packet->hdr.size has already been compared with SOF_IPC_MSG_MAX_SIZE */
if (sizeof(*packet) + sizeof(*elem) * packet->elem_cnt != packet->hdr.size) {
@ -917,6 +915,9 @@ static int ipc_trace_filter_update(uint32_t header)
tr_info(&ipc_tr, "ipc: trace_filter_update received, size %d elems",
packet->elem_cnt);
elem = packet->elems;
end = &packet->elems[packet->elem_cnt];
/* read each filter set and update selected components trace settings */
while (elem != end) {
next_elem = trace_filter_fill(elem, end, &filter);