Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 063f097f authored by Colin Ian King's avatar Colin Ian King Committed by Greg Kroah-Hartman
Browse files

intel_th: msu: Fix missing allocation failure check on a kstrndup



Commit 615c164d ("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: 615c164d ("intel_th: msu: Introduce buffer interface")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
[alexander.shishkin: amended the commit message]
Signed-off-by: default avatarAlexander Shishkin <alexander.shishkin@linux.intel.com>
Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/lkml/20190726120421.9650-1-colin.king@canonical.com/
Link: https://lore.kernel.org/r/20191028070651.9770-4-alexander.shishkin@linux.intel.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e5a340f7
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -1848,6 +1848,9 @@ mode_store(struct device *dev, struct device_attribute *attr, const char *buf,
		len = cp - buf;
		len = cp - buf;


	mode = kstrndup(buf, len, GFP_KERNEL);
	mode = kstrndup(buf, len, GFP_KERNEL);
	if (!mode)
		return -ENOMEM;

	i = match_string(msc_mode, ARRAY_SIZE(msc_mode), mode);
	i = match_string(msc_mode, ARRAY_SIZE(msc_mode), mode);
	if (i >= 0)
	if (i >= 0)
		goto found;
		goto found;