intel_th: msu: Fix possible memory leak in mode_store()
Subsystems (3)
PATCH 1/1 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 <[email protected]>
--- drivers/hwtracing/intel_th/msu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/hwtracing/intel_th/msu.c +3 -1
@@ -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) {