Skip to content

Commit 063f097

Browse files
Colin Ian Kinggregkh
authored andcommitted
intel_th: msu: Fix missing allocation failure check on a kstrndup
Commit 615c164 ("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: 615c164 ("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]>
1 parent e5a340f commit 063f097

File tree

1 file changed

+3
-0
lines changed
  • drivers/hwtracing/intel_th

1 file changed

+3
-0
lines changed

drivers/hwtracing/intel_th/msu.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,6 +1848,9 @@ mode_store(struct device *dev, struct device_attribute *attr, const char *buf,
18481848
len = cp - buf;
18491849

18501850
mode = kstrndup(buf, len, GFP_KERNEL);
1851+
if (!mode)
1852+
return -ENOMEM;
1853+
18511854
i = match_string(msc_mode, ARRAY_SIZE(msc_mode), mode);
18521855
if (i >= 0)
18531856
goto found;

0 commit comments

Comments
 (0)