All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next] intel_th: msu: Fix possible memory leak in mode_store()
@ 2019-08-01  1:38 ` Wei Yongjun
  0 siblings, 0 replies; 2+ messages in thread
From: Wei Yongjun @ 2019-08-01  1:38 UTC (permalink / raw
  To: Alexander Shishkin; +Cc: Wei Yongjun, linux-kernel, kernel-janitors

'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>
---
 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 fc9f15f36ad4..2e7a04f566d4 100644
--- a/drivers/hwtracing/intel_th/msu.c
+++ b/drivers/hwtracing/intel_th/msu.c
@@ -1849,8 +1849,10 @@ mode_store(struct device *dev, struct device_attribute *attr, const char *buf,
 
 	mode = kstrndup(buf, len, GFP_KERNEL);
 	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) {




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH -next] intel_th: msu: Fix possible memory leak in mode_store()
@ 2019-08-01  1:38 ` Wei Yongjun
  0 siblings, 0 replies; 2+ messages in thread
From: Wei Yongjun @ 2019-08-01  1:38 UTC (permalink / raw
  To: Alexander Shishkin; +Cc: Wei Yongjun, linux-kernel, kernel-janitors

'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>
---
 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 fc9f15f36ad4..2e7a04f566d4 100644
--- a/drivers/hwtracing/intel_th/msu.c
+++ b/drivers/hwtracing/intel_th/msu.c
@@ -1849,8 +1849,10 @@ mode_store(struct device *dev, struct device_attribute *attr, const char *buf,
 
 	mode = kstrndup(buf, len, GFP_KERNEL);
 	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) {

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-08-01  1:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-01  1:38 [PATCH -next] intel_th: msu: Fix possible memory leak in mode_store() Wei Yongjun
2019-08-01  1:38 ` Wei Yongjun

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.