diff options
author | Kangjie Lu <kjlu@umn.edu> | 2019-03-25 15:23:08 -0500 |
---|---|---|
committer | Mika Westerberg <mika.westerberg@linux.intel.com> | 2019-03-28 11:30:47 +0300 |
commit | 6183d5a51866f3acdeeb66b75e87d44025b01a55 (patch) | |
tree | deb7832ddcc320a2e31509df57b4e86308b12061 /drivers/thunderbolt | |
parent | 48f40b96de2c790eac6114e3e879a48fe9f89349 (diff) |
thunderbolt: property: Fix a missing check of kzalloc
No check is enforced for the return value of kzalloc,
which may lead to NULL-pointer dereference.
The patch fixes this issue.
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Diffstat (limited to 'drivers/thunderbolt')
-rw-r--r-- | drivers/thunderbolt/property.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/thunderbolt/property.c b/drivers/thunderbolt/property.c index 841314deb446..d5b0cdb8f0b1 100644 --- a/drivers/thunderbolt/property.c +++ b/drivers/thunderbolt/property.c @@ -587,7 +587,12 @@ int tb_property_add_text(struct tb_property_dir *parent, const char *key, return -ENOMEM; property->length = size / 4; - property->value.data = kzalloc(size, GFP_KERNEL); + property->value.text = kzalloc(size, GFP_KERNEL); + if (!property->value.text) { + kfree(property); + return -ENOMEM; + } + strcpy(property->value.text, text); list_add_tail(&property->list, &parent->properties); |