* [PATCH] thunderbolt: fix a missing check of kmemdup
@ 2019-03-14 6:55 Kangjie Lu
2019-03-15 9:12 ` Mika Westerberg
0 siblings, 1 reply; 2+ messages in thread
From: Kangjie Lu @ 2019-03-14 6:55 UTC (permalink / raw)
To: kjlu
Cc: pakki001, Andreas Noever, Michael Jamet, Mika Westerberg,
Yehezkel Bernat, linux-kernel
kmemdup may fail and return NULL. The fix adds a check and returns
NULL in case it fails to avoid NULL pointer dereferecen.
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
drivers/thunderbolt/property.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/thunderbolt/property.c b/drivers/thunderbolt/property.c
index ee76449524a3..841314deb446 100644
--- a/drivers/thunderbolt/property.c
+++ b/drivers/thunderbolt/property.c
@@ -176,6 +176,10 @@ static struct tb_property_dir *__tb_property_parse_dir(const u32 *block,
} else {
dir->uuid = kmemdup(&block[dir_offset], sizeof(*dir->uuid),
GFP_KERNEL);
+ if (!dir->uuid) {
+ tb_property_free_dir(dir);
+ return NULL;
+ }
content_offset = dir_offset + 4;
content_len = dir_len - 4; /* Length includes UUID */
}
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] thunderbolt: fix a missing check of kmemdup
2019-03-14 6:55 [PATCH] thunderbolt: fix a missing check of kmemdup Kangjie Lu
@ 2019-03-15 9:12 ` Mika Westerberg
0 siblings, 0 replies; 2+ messages in thread
From: Mika Westerberg @ 2019-03-15 9:12 UTC (permalink / raw)
To: Kangjie Lu
Cc: pakki001, Andreas Noever, Michael Jamet, Yehezkel Bernat, linux-kernel
On Thu, Mar 14, 2019 at 01:55:31AM -0500, Kangjie Lu wrote:
> kmemdup may fail and return NULL. The fix adds a check and returns
> NULL in case it fails to avoid NULL pointer dereferecen.
>
> 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-15 9:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-14 6:55 [PATCH] thunderbolt: fix a missing check of kmemdup Kangjie Lu
2019-03-15 9:12 ` 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.