summaryrefslogtreecommitdiffstats
path: root/drivers/thunderbolt/property.c
diff options
context:
space:
mode:
authorKangjie Lu2019-03-25 21:23:08 +0100
committerMika Westerberg2019-03-28 09:30:47 +0100
commit6183d5a51866f3acdeeb66b75e87d44025b01a55 (patch)
treedeb7832ddcc320a2e31509df57b4e86308b12061 /drivers/thunderbolt/property.c
parentthunderbolt: xdomain: Fix to check return value of kmemdup (diff)
downloadkernel-qcow2-linux-6183d5a51866f3acdeeb66b75e87d44025b01a55.tar.gz
kernel-qcow2-linux-6183d5a51866f3acdeeb66b75e87d44025b01a55.tar.xz
kernel-qcow2-linux-6183d5a51866f3acdeeb66b75e87d44025b01a55.zip
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/property.c')
-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);