Skip to content

Commit fef310e

Browse files
committed
tlv: guard tlv_value_get() loop against NULL from tlv_next()
Add 'tlv &&' to the while-loop condition in tlv_value_get(). tlv_next() returns NULL on malformed TLV (length not a multiple of 4). The existing condition '(uint32_t)tlv < end_addr' does not catch NULL, causing a NULL dereference on the next iteration. This is reachable from host IPC via copier_host_create() which parses optional TLV data appended to the copier module configuration blob. Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
1 parent b06121a commit fef310e

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/include/sof/tlv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static inline void tlv_value_get(const void *data,
9191
const struct sof_tlv *tlv = (const struct sof_tlv *)data;
9292
const uint32_t end_addr = (uint32_t)data + size;
9393

94-
while ((uint32_t)tlv < end_addr) {
94+
while (tlv && (uint32_t)tlv < end_addr) {
9595
if (tlv->type == type) {
9696
*value = (void *)tlv->value;
9797
*length = tlv->length;

0 commit comments

Comments
 (0)