Skip to content

Commit 2308cf4

Browse files
abonislawskilgirdwood
authored andcommitted
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 aceccc1 commit 2308cf4

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
@@ -1306,7 +1306,7 @@ int ipc4_find_dma_config_multiple(struct ipc_config_dai *dai, uint8_t *data_buff
13061306
struct ipc_dma_config *dma_cfg;
13071307
struct sof_tlv *tlvs;
13081308

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

0 commit comments

Comments
 (0)