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,
	Wei Yongjun <weiyongjun1@huawei.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [GIT PULL 5/7] intel_th: msu: Fix possible memory leak in mode_store()
Date: Mon, 28 Oct 2019 09:06:49 +0200	[thread overview]
Message-ID: <20191028070651.9770-6-alexander.shishkin@linux.intel.com> (raw)
In-Reply-To: <20191028070651.9770-1-alexander.shishkin@linux.intel.com>

From: Wei Yongjun <weiyongjun1@huawei.com>

'mode' is malloced in mode_store() and should be freed before leaving
from the error handling cases, otherwise it will cause memory leak.

Fixes: 615c164da0eb ("intel_th: msu: Introduce buffer interface")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
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/20190801013825.182543-1-weiyongjun1@huawei.com/
---
 drivers/hwtracing/intel_th/msu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/hwtracing/intel_th/msu.c b/drivers/hwtracing/intel_th/msu.c
index 9dc9ae87b5e5..6d240dfae9d9 100644
--- a/drivers/hwtracing/intel_th/msu.c
+++ b/drivers/hwtracing/intel_th/msu.c
@@ -1852,8 +1852,10 @@ mode_store(struct device *dev, struct device_attribute *attr, const char *buf,
 		return -ENOMEM;
 
 	i = match_string(msc_mode, ARRAY_SIZE(msc_mode), mode);
-	if (i >= 0)
+	if (i >= 0) {
+		kfree(mode);
 		goto found;
+	}
 
 	/* Buffer sinks only work with a usable IRQ */
 	if (!msc->do_irq) {
-- 
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 ` [GIT PULL 3/7] intel_th: msu: Fix missing allocation failure check on a kstrndup Alexander Shishkin
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 ` Alexander Shishkin [this message]
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-6-alexander.shishkin@linux.intel.com \
    --to=alexander.shishkin@linux.intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=weiyongjun1@huawei.com \
    /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.