diff options
author | Colin Ian King <[email protected]> | 2019-10-28 09:06:47 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <[email protected]> | 2019-11-04 15:01:23 +0100 |
commit | 063f097fd65a90fca2cd49411a2d6e35b8ca25db (patch) | |
tree | f423370f4fad75a99996c1cf433d483abfe1b662 | |
parent | e5a340f770278f4de42e8bac19f2ebeb77ddfae4 (diff) |
intel_th: msu: Fix missing allocation failure check on a kstrndup
Commit 615c164da0eb ("intel_th: msu: Introduce buffer interface") forgot
to add a NULL pointer check for the value returned from kstrdup(), which
will be troublesome if the allocation fails.
Fix that by adding the check.
Addresses-Coverity: ("Dereference null return")
Fixes: 615c164da0eb ("intel_th: msu: Introduce buffer interface")
Signed-off-by: Colin Ian King <[email protected]>
[alexander.shishkin: amended the commit message]
Signed-off-by: Alexander Shishkin <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
Link: https://lore.kernel.org/lkml/[email protected]/
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
-rw-r--r-- | drivers/hwtracing/intel_th/msu.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/hwtracing/intel_th/msu.c b/drivers/hwtracing/intel_th/msu.c index 51021020fa3f..201a166fdff5 100644 --- a/drivers/hwtracing/intel_th/msu.c +++ b/drivers/hwtracing/intel_th/msu.c @@ -1848,6 +1848,9 @@ mode_store(struct device *dev, struct device_attribute *attr, const char *buf, len = cp - buf; mode = kstrndup(buf, len, GFP_KERNEL); + if (!mode) + return -ENOMEM; + i = match_string(msc_mode, ARRAY_SIZE(msc_mode), mode); if (i >= 0) goto found; |