lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 22 Jul 2021 18:56:11 +0800
From:   Dongliang Mu <mudongliangabcd@...il.com>
To:     Vinod Koul <vkoul@...nel.org>,
        Bard Liao <yung-chuan.liao@...ux.intel.com>,
        Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>,
        Sanyog Kale <sanyog.r.kale@...el.com>
Cc:     dan.carpenter@...cle.com, Dongliang Mu <mudongliangabcd@...il.com>,
        alsa-devel@...a-project.org, linux-kernel@...r.kernel.org
Subject: [PATCH] soundwire: stream: add s_rt into slave_rt_list before sdw_config_stream

The commit 48f17f96a817 ("soundwire: stream: fix memory leak in stream
config error path") fixes the memory leak by implicitly freeing the s_rt
object. However, this fixing style is not very good.

The better fix is to move list_add_tail before sdw_config_stream and
revert the previous commit.

Signed-off-by: Dongliang Mu <mudongliangabcd@...il.com>
---
 drivers/soundwire/stream.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c
index 1a18308f4ef4..66a4ce4f923f 100644
--- a/drivers/soundwire/stream.c
+++ b/drivers/soundwire/stream.c
@@ -1373,19 +1373,11 @@ int sdw_stream_add_slave(struct sdw_slave *slave,
 		goto stream_error;
 	}
 
+	list_add_tail(&s_rt->m_rt_node, &m_rt->slave_rt_list);
+
 	ret = sdw_config_stream(&slave->dev, stream, stream_config, true);
-	if (ret) {
-		/*
-		 * sdw_release_master_stream will release s_rt in slave_rt_list in
-		 * stream_error case, but s_rt is only added to slave_rt_list
-		 * when sdw_config_stream is successful, so free s_rt explicitly
-		 * when sdw_config_stream is failed.
-		 */
-		kfree(s_rt);
+	if (ret)
 		goto stream_error;
-	}
-
-	list_add_tail(&s_rt->m_rt_node, &m_rt->slave_rt_list);
 
 	ret = sdw_slave_port_config(slave, s_rt, port_config, num_ports);
 	if (ret)
-- 
2.25.1

Powered by blists - more mailing lists