Skip to content

Commit b06121a

Browse files
committed
ipc4: helper: guard TLV loop against NULL from tlv_next()
Add 'tlvs &&' to the for-loop condition in ipc4_find_dma_config_multiple(). tlv_next() returns NULL on malformed TLV (length not a multiple of 4). The existing loop condition '(uint32_t)tlvs < end_addr' does not catch NULL (0 < end_addr is always true), causing a NULL pointer dereference in the next iteration via tlv_value_ptr_get() or tlv_next(). Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
1 parent 3c391c6 commit b06121a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/ipc/ipc4/helper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1307,7 +1307,7 @@ int ipc4_find_dma_config_multiple(struct ipc_config_dai *dai, uint8_t *data_buff
13071307
struct ipc_dma_config *dma_cfg;
13081308
struct sof_tlv *tlvs;
13091309

1310-
for (tlvs = (struct sof_tlv *)data_buffer; (uint32_t)tlvs < end_addr;
1310+
for (tlvs = (struct sof_tlv *)data_buffer; tlvs && (uint32_t)tlvs < end_addr;
13111311
tlvs = tlv_next(tlvs)) {
13121312
dma_cfg = tlv_value_ptr_get(tlvs, GTW_DMA_CONFIG_ID);
13131313
if (!dma_cfg)

0 commit comments

Comments
 (0)