Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e4dfdd58 authored by Kangjie Lu's avatar Kangjie Lu Committed by Mika Westerberg
Browse files

thunderbolt: Fix a missing check of kmemdup



kmemdup may fail and return NULL. The fix adds a check and returns
NULL in case it fails to avoid NULL pointer dereferecen.

Signed-off-by: default avatarKangjie Lu <kjlu@umn.edu>
Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
parent 106204b5
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -176,6 +176,10 @@ static struct tb_property_dir *__tb_property_parse_dir(const u32 *block,
	} else {
		dir->uuid = kmemdup(&block[dir_offset], sizeof(*dir->uuid),
				    GFP_KERNEL);
		if (!dir->uuid) {
			tb_property_free_dir(dir);
			return NULL;
		}
		content_offset = dir_offset + 4;
		content_len = dir_len - 4; /* Length includes UUID */
	}