From 8a01c3ed0fc0f8e3a47b1ccd0a831740810cf4b8 Mon Sep 17 00:00:00 2001 From: yingdeng Date: Fri, 9 Aug 2024 16:59:09 +0800 Subject: [PATCH] coresight: tmc: etf: Free its buffer and set NULL when etf can't be enabled In function tmc_enable_etf_sink_sysfs, the local variable buf was allocated and assigned to drvdata->buffer, and buf will be freed because etf can't be enabled, but drvdata->buffer still point to the address. So in function tmc_read_unprepare_etb, beacause drvdata->mode is CS_MODE_DISABLED, local variable buf was assigned by drvdata->buf and free again. Change-Id: I7d25e7db0a983fc134e8d8dfb954936233f0d167 Signed-off-by: yingdeng --- drivers/hwtracing/coresight/coresight-tmc-etf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c index 286e08135e15..a093e7687253 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c @@ -247,7 +247,8 @@ static int tmc_enable_etf_sink_sysfs(struct coresight_device *csdev) atomic_inc(csdev->refcnt); } else { /* Free up the buffer if we failed to enable */ - used = false; + kfree(drvdata->buf); + drvdata->buf = NULL; } out: spin_unlock_irqrestore(&drvdata->spinlock, flags);