mirror of https://gitee.com/openkylin/linux.git
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: Kangjie Lu <kjlu@umn.edu> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
This commit is contained in:
parent
106204b56f
commit
e4dfdd5804
|
@ -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 */
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue