All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] thunderbolt: property: fix a NULL pointer dereference
@ 2019-03-12  8:33 Kangjie Lu
  2019-03-13 11:41 ` Mika Westerberg
  0 siblings, 1 reply; 2+ messages in thread
From: Kangjie Lu @ 2019-03-12  8:33 UTC (permalink / raw)
  To: kjlu
  Cc: pakki001, Andreas Noever, Michael Jamet, Mika Westerberg,
	Yehezkel Bernat, linux-kernel

In case kzalloc fails, the fix releases resources and returns
-ENOMEM to avoid the NULL pointer dereference.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 drivers/thunderbolt/property.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/thunderbolt/property.c b/drivers/thunderbolt/property.c
index b2f0d6386cee..ee76449524a3 100644
--- a/drivers/thunderbolt/property.c
+++ b/drivers/thunderbolt/property.c
@@ -548,6 +548,11 @@ int tb_property_add_data(struct tb_property_dir *parent, const char *key,
 
 	property->length = size / 4;
 	property->value.data = kzalloc(size, GFP_KERNEL);
+	if (!property->value.data) {
+		kfree(property);
+		return -ENOMEM;
+	}
+
 	memcpy(property->value.data, buf, buflen);
 
 	list_add_tail(&property->list, &parent->properties);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] thunderbolt: property: fix a NULL pointer dereference
  2019-03-12  8:33 [PATCH] thunderbolt: property: fix a NULL pointer dereference Kangjie Lu
@ 2019-03-13 11:41 ` Mika Westerberg
  0 siblings, 0 replies; 2+ messages in thread
From: Mika Westerberg @ 2019-03-13 11:41 UTC (permalink / raw)
  To: Kangjie Lu
  Cc: pakki001, Andreas Noever, Michael Jamet, Yehezkel Bernat, linux-kernel

On Tue, Mar 12, 2019 at 03:33:28AM -0500, Kangjie Lu wrote:
> In case kzalloc fails, the fix releases resources and returns
> -ENOMEM to avoid the NULL pointer dereference.
> 
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>

Applied, thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-03-13 11:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-12  8:33 [PATCH] thunderbolt: property: fix a NULL pointer dereference Kangjie Lu
2019-03-13 11:41 ` Mika Westerberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.