summaryrefslogtreecommitdiff
path: root/drivers/thunderbolt
diff options
context:
space:
mode:
authorKangjie Lu <kjlu@umn.edu>2019-03-25 23:23:08 +0300
committerMika Westerberg <mika.westerberg@linux.intel.com>2019-03-28 11:30:47 +0300
commit6183d5a51866f3acdeeb66b75e87d44025b01a55 (patch)
treedeb7832ddcc320a2e31509df57b4e86308b12061 /drivers/thunderbolt
parent48f40b96de2c790eac6114e3e879a48fe9f89349 (diff)
downloadlinux-6183d5a51866f3acdeeb66b75e87d44025b01a55.tar.xz
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.c7
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);