All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Shishkin <alexander.shishkin@linux.intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org,
	Colin Ian King <colin.king@canonical.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [GIT PULL 3/7] intel_th: msu: Fix missing allocation failure check on a kstrndup
Date: Mon, 28 Oct 2019 09:06:47 +0200	[thread overview]
Message-ID: <20191028070651.9770-4-alexander.shishkin@linux.intel.com> (raw)
In-Reply-To: <20191028070651.9770-1-alexander.shishkin@linux.intel.com>

From: Colin Ian King <colin.king@canonical.com>

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 <colin.king@canonical.com>
[alexander.shishkin: amended the commit message]
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/lkml/20190726120421.9650-1-colin.king@canonical.com/
---
 drivers/hwtracing/intel_th/msu.c | 3 +++
 1 file changed, 3 insertions(+)

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;
-- 
2.23.0


  parent reply	other threads:[~2019-10-28  7:07 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-28  7:06 [GIT PULL 0/7] intel_th: Fixes for v5.4 Alexander Shishkin
2019-10-28  7:06 ` [GIT PULL 1/7] intel_th: gth: Fix the window switching sequence Alexander Shishkin
2019-11-02 17:14   ` Greg Kroah-Hartman
2019-11-04  6:25     ` Alexander Shishkin
2019-11-04  6:35       ` Greg Kroah-Hartman
2019-11-04  6:54         ` Alexander Shishkin
2019-10-28  7:06 ` [GIT PULL 2/7] intel_th: msu: Fix an uninitialized mutex Alexander Shishkin
2019-11-02 17:14   ` Greg Kroah-Hartman
2019-11-04  6:27     ` Alexander Shishkin
2019-10-28  7:06 ` Alexander Shishkin [this message]
2019-10-28  7:06 ` [GIT PULL 4/7] intel_th: msu: Fix overflow in shift of an unsigned int Alexander Shishkin
2019-10-28  7:06 ` [GIT PULL 5/7] intel_th: msu: Fix possible memory leak in mode_store() Alexander Shishkin
2019-10-28  7:06 ` [GIT PULL 6/7] intel_th: pci: Add Comet Lake PCH support Alexander Shishkin
2019-10-28  7:06 ` [GIT PULL 7/7] intel_th: pci: Add Jasper " Alexander Shishkin
2019-11-04 14:02 ` [GIT PULL 0/7] intel_th: Fixes for v5.4 Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191028070651.9770-4-alexander.shishkin@linux.intel.com \
    --to=alexander.shishkin@linux.intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=colin.king@canonical.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.