diff options
author | Rander Wang <rander.wang@intel.com> | 2021-03-31 02:46:10 +0200 |
---|---|---|
committer | Vinod Koul <vkoul@kernel.org> | 2021-04-06 06:51:35 +0200 |
commit | 48f17f96a81763c7c8bf5500460a359b9939359f (patch) | |
tree | a26084a24568c2476368f7a676ad24cf38bea913 /drivers/soundwire | |
parent | soundwire: qcom: use signed variable for error return (diff) | |
download | linux-48f17f96a81763c7c8bf5500460a359b9939359f.tar.xz linux-48f17f96a81763c7c8bf5500460a359b9939359f.zip |
soundwire: stream: fix memory leak in stream config error path
When stream config is failed, master runtime will release all
slave runtime in the slave_rt_list, but slave runtime is not
added to the list at this time. This patch frees slave runtime
in the config error path to fix the memory leak.
Fixes: 89e590535f32 ("soundwire: Add support for SoundWire stream management")
Signed-off-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Keyon Jie <yang.jie@intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20210331004610.12242-1-yung-chuan.liao@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Diffstat (limited to 'drivers/soundwire')
-rw-r--r-- | drivers/soundwire/stream.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c index 9c064b672745..1eaedaaba094 100644 --- a/drivers/soundwire/stream.c +++ b/drivers/soundwire/stream.c @@ -1375,8 +1375,16 @@ int sdw_stream_add_slave(struct sdw_slave *slave, } ret = sdw_config_stream(&slave->dev, stream, stream_config, true); - if (ret) + 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); goto stream_error; + } list_add_tail(&s_rt->m_rt_node, &m_rt->slave_rt_list); |