Commit 48f17f96 authored by Rander Wang's avatar Rander Wang Committed by Vinod Koul

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: 89e59053 ("soundwire: Add support for SoundWire stream management")
Signed-off-by: default avatarRander Wang <rander.wang@intel.com>
Reviewed-by: default avatarKeyon Jie <yang.jie@intel.com>
Reviewed-by: default avatarGuennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20210331004610.12242-1-yung-chuan.liao@linux.intel.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent b26b4874
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment