stm class: Fix a double free of stm_source_device [Linux 4.19.70]

This Linux kernel change "stm class: Fix a double free of stm_source_device" is included in the Linux 4.19.70 release. This change is authored by Ding Xiang <dingxiang [at]> on Wed Aug 21 10:49:52 2019 +0300. The commit for this change in Linux stable tree is cad1d3b (patch) which is from upstream commit 961b6ff. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream 961b6ff.

stm class: Fix a double free of stm_source_device

commit 961b6ffe0e2c403b09a8efe4a2e986b3c415391a upstream.

In the error path of stm_source_register_device(), the kfree is
unnecessary, as the put_device() before it ends up calling
stm_source_device_release() to free stm_source_device, leading to
a double free at the outer kfree() call. Remove it.

Signed-off-by: Ding Xiang <>
Signed-off-by: Alexander Shishkin <>
Fixes: 7bd1d4093c2fa ("stm class: Introduce an abstraction for System Trace Module devices")
Cc: # v4.4+
Signed-off-by: Greg Kroah-Hartman <>

There is one line of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/hwtracing/stm/core.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c
index 9ec9197..eeba421d 100644
--- a/drivers/hwtracing/stm/core.c
+++ b/drivers/hwtracing/stm/core.c
@@ -1098,7 +1098,6 @@ int stm_source_register_device(struct device *parent,

-   kfree(src);

    return err;

Leave a Reply

Your email address will not be published. Required fields are marked *