[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20191120152632.6110-1-wenyang@linux.alibaba.com>
Date: Wed, 20 Nov 2019 23:26:32 +0800
From: Wen Yang <wenyang@...ux.alibaba.com>
To: alexander.shishkin@...ux.intel.com, mcoquelin.stm32@...il.com,
alexandre.torgue@...co
Cc: zhiche.yy@...baba-inc.com, xlpang@...ux.alibaba.com,
Wen Yang <wenyang@...ux.alibaba.com>,
Alexandre Torgue <alexandre.torgue@...com>,
linux-stm32@...md-mailman.stormreply.com,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: [PATCH] stm class: fix a double free in stm_register_device()
In the error path of stm_register_device(), the kfree is
unnecessary, as the put_device() before it ends up calling
stm_device_release() to free stm_device.
Fixes: 7bd1d4093c2fa ("stm class: Introduce an abstraction for System Trace Module devices")
Signed-off-by: Wen Yang <wenyang@...ux.alibaba.com>
Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: Maxime Coquelin <mcoquelin.stm32@...il.com>
Cc: Alexandre Torgue <alexandre.torgue@...com>
Cc: linux-stm32@...md-mailman.stormreply.com
Cc: linux-arm-kernel@...ts.infradead.org
Cc: linux-kernel@...r.kernel.org
---
drivers/hwtracing/stm/core.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c
index 2712e69..55c69d8 100644
--- a/drivers/hwtracing/stm/core.c
+++ b/drivers/hwtracing/stm/core.c
@@ -868,8 +868,10 @@ int stm_register_device(struct device *parent, struct stm_data *stm_data,
return -ENOMEM;
stm->major = register_chrdev(0, stm_data->name, &stm_fops);
- if (stm->major < 0)
- goto err_free;
+ if (stm->major < 0) {
+ vfree(stm);
+ return err;
+ }
device_initialize(&stm->dev);
stm->dev.devt = MKDEV(stm->major, 0);
@@ -915,8 +917,6 @@ int stm_register_device(struct device *parent, struct stm_data *stm_data,
/* matches device_initialize() above */
put_device(&stm->dev);
-err_free:
- vfree(stm);
return err;
}
--
1.8.3.1
Powered by blists - more mailing lists