diff options
author | Kangjie Lu <kjlu@umn.edu> | 2019-03-25 23:23:08 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-05-31 16:43:45 +0300 |
commit | f0cc2ffb37b407b79875d1ee9412f3639dc81f37 (patch) | |
tree | d738d5bbe0465e60e24dd41cbd17f38d2cd5ac91 /drivers/thunderbolt | |
parent | d1d090c475348da13e3507e49a837c26632a1736 (diff) | |
download | linux-f0cc2ffb37b407b79875d1ee9412f3639dc81f37.tar.xz |
thunderbolt: property: Fix a missing check of kzalloc
[ Upstream commit 6183d5a51866f3acdeeb66b75e87d44025b01a55 ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
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 b2f0d6386cee..ead18c532b53 100644 --- a/drivers/thunderbolt/property.c +++ b/drivers/thunderbolt/property.c @@ -578,7 +578,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); |