summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei Yongjun <weiyongjun1@huawei.com>2019-10-28 03:06:49 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-11-04 09:01:24 -0500
commit1fa1b6ca0fda97cbfccdc6b80b1a6b2920751665 (patch)
treeefc4f9eda54c0d063e4fedd6e0a07225334f2554
parent8e3ef7b444aec3d1059085ce41edaa76ee7340e7 (diff)
intel_th: msu: Fix possible memory leak in mode_store()
'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/ Link: https://lore.kernel.org/r/20191028070651.9770-6-alexander.shishkin@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/hwtracing/intel_th/msu.c4
1 files changed, 3 insertions, 1 deletions
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,
1852 return -ENOMEM; 1852 return -ENOMEM;
1853 1853
1854 i = match_string(msc_mode, ARRAY_SIZE(msc_mode), mode); 1854 i = match_string(msc_mode, ARRAY_SIZE(msc_mode), mode);
1855 if (i >= 0) 1855 if (i >= 0) {
1856 kfree(mode);
1856 goto found; 1857 goto found;
1858 }
1857 1859
1858 /* Buffer sinks only work with a usable IRQ */ 1860 /* Buffer sinks only work with a usable IRQ */
1859 if (!msc->do_irq) { 1861 if (!msc->do_irq) {