Skip to content

Commit

Permalink
intel_th: msu: Fix possible memory leak in mode_store()
Browse files Browse the repository at this point in the history
'mode' is malloced in mode_store() and should be freed before leaving
from the error handling cases, otherwise it will cause memory leak.

Fixes: 615c164 ("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>
  • Loading branch information
Wei Yongjun authored and Greg Kroah-Hartman committed Nov 4, 2019
1 parent 8e3ef7b commit 1fa1b6c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/hwtracing/intel_th/msu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 1fa1b6c

Please sign in to comment.