From: Dongliang Mu <mudongliangabcd@gmail.com>
To: Vinod Koul <vkoul@kernel.org>,
Bard Liao <yung-chuan.liao@linux.intel.com>,
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
Sanyog Kale <sanyog.r.kale@intel.com>
Cc: dan.carpenter@oracle.com,
Dongliang Mu <mudongliangabcd@gmail.com>,
alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org
Subject: [PATCH] soundwire: stream: add s_rt into slave_rt_list before sdw_config_stream
Date: Thu, 22 Jul 2021 18:56:11 +0800 [thread overview]
Message-ID: <20210722105611.1582803-1-mudongliangabcd@gmail.com> (raw)
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@gmail.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
next reply other threads:[~2021-07-22 10:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-22 10:56 Dongliang Mu [this message]
2021-07-22 11:16 ` Dan Carpenter
2021-07-22 11:24 ` Dongliang Mu
2021-07-22 11:36 ` Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210722105611.1582803-1-mudongliangabcd@gmail.com \
--to=mudongliangabcd@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=dan.carpenter@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=sanyog.r.kale@intel.com \
--cc=vkoul@kernel.org \
--cc=yung-chuan.liao@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®