#
bf75ba4b |
| 25-Jan-2022 |
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> |
soundwire: stream: move sdw_alloc_slave_rt() before 'master' helpers
Code move before splitting the function in two. No functionality change.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossa
soundwire: stream: move sdw_alloc_slave_rt() before 'master' helpers
Code move before splitting the function in two. No functionality change.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@intel.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20220126011715.28204-12-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
show more ...
|
#
bb10659a |
| 25-Jan-2022 |
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> |
soundwire: stream: split sdw_alloc_master_rt() in alloc and config
Split the two parts so that we can do multiple configurations during ALSA/ASoC hw_params stage. Also follow existing convention sdw
soundwire: stream: split sdw_alloc_master_rt() in alloc and config
Split the two parts so that we can do multiple configurations during ALSA/ASoC hw_params stage. Also follow existing convention sdw_<object>_<action> used at lower level.
No functionality change here.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@intel.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20220126011715.28204-11-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
show more ...
|
#
1a21892d |
| 25-Jan-2022 |
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> |
soundwire: stream: simplify sdw_alloc_master_rt()
Only do the allocation in that function, and move check for allocation in the caller. This will it easier to split allocation and configuration.
No
soundwire: stream: simplify sdw_alloc_master_rt()
Only do the allocation in that function, and move check for allocation in the caller. This will it easier to split allocation and configuration.
No functionality change in this patch.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@intel.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20220126011715.28204-10-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
show more ...
|
#
c7aa9d77 |
| 25-Jan-2022 |
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> |
soundwire: stream: group sdw_port and sdw_master/slave_port functions
re-group all the helpers in one location with a code move. For consistency the 'slave' helpers are placed before the 'master' he
soundwire: stream: group sdw_port and sdw_master/slave_port functions
re-group all the helpers in one location with a code move. For consistency the 'slave' helpers are placed before the 'master' helpers.
Also remove unused arguments and rename the 'release' function to 'free' for consistency.
No functional change in this patch.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@intel.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20220126011715.28204-9-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
show more ...
|
#
4bbd6d55 |
| 25-Jan-2022 |
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> |
soundwire: stream: add 'slave' prefix for port range checks
We can only check for Slave port ranges, the ports are not defined at the Master level. Also move the function to the 'slave port' block.
soundwire: stream: add 'slave' prefix for port range checks
We can only check for Slave port ranges, the ports are not defined at the Master level. Also move the function to the 'slave port' block.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@intel.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20220126011715.28204-8-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
show more ...
|
#
1508876f |
| 25-Jan-2022 |
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> |
soundwire: stream: split alloc and config in two functions
Continue the split with two functions for master and slave, and remove unused arguments.
Signed-off-by: Pierre-Louis Bossart <pierre-louis
soundwire: stream: split alloc and config in two functions
Continue the split with two functions for master and slave, and remove unused arguments.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@intel.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20220126011715.28204-7-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
show more ...
|
#
2811221a |
| 25-Jan-2022 |
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> |
soundwire: stream: split port allocation and configuration loops
Split loops before moving the allocation and configuration to separate functions.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.
soundwire: stream: split port allocation and configuration loops
Split loops before moving the allocation and configuration to separate functions.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@intel.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20220126011715.28204-6-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
show more ...
|
#
6ccf3292 |
| 25-Jan-2022 |
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> |
soundwire: stream: add alloc/config/free helpers for ports
The existing code only has a config helper that allocates memory, start adding alloc/config/free for ports, as a first step in the simplifi
soundwire: stream: add alloc/config/free helpers for ports
The existing code only has a config helper that allocates memory, start adding alloc/config/free for ports, as a first step in the simplification of the stream API.
This change removes a kfree() on a configuration error, this should have not impact on existing platforms and error handling will be revisited in follow-up patches to make sure invalid configurations have not impact on memory allocation.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@intel.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20220126011715.28204-5-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
show more ...
|
#
5ec17b98 |
| 25-Jan-2022 |
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> |
soundwire: stream: simplify check on port range
Pass the index directly to sdw_is_valid_port_range(), this will be useful for further simplifications.
Signed-off-by: Pierre-Louis Bossart <pierre-lo
soundwire: stream: simplify check on port range
Pass the index directly to sdw_is_valid_port_range(), this will be useful for further simplifications.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@intel.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20220126011715.28204-4-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
show more ...
|
#
823ca885 |
| 25-Jan-2022 |
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> |
soundwire: stream: add slave runtime to list earlier
sdw_config_stream() only verifies the compatibility between information provided by the Slave driver and the stream configuration.
There is no p
soundwire: stream: add slave runtime to list earlier
sdw_config_stream() only verifies the compatibility between information provided by the Slave driver and the stream configuration.
There is no problem if we add the slave runtime to the list earlier.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@intel.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20220126011715.28204-3-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
show more ...
|
#
ad027fa2 |
| 25-Jan-2022 |
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> |
soundwire: stream: remove unused parameter in sdw_stream_add_slave
The stream parameter is not used, remove before further simplifications.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart
soundwire: stream: remove unused parameter in sdw_stream_add_slave
The stream parameter is not used, remove before further simplifications.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@intel.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20220126011715.28204-2-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
show more ...
|
#
e8444560 |
| 23-Dec-2021 |
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> |
ASoC/SoundWire: dai: expand 'stream' concept beyond SoundWire
The HDAudio ASoC support relies on the set_tdm_slots() helper to store the HDaudio stream tag in the tx_mask. This only works because of
ASoC/SoundWire: dai: expand 'stream' concept beyond SoundWire
The HDAudio ASoC support relies on the set_tdm_slots() helper to store the HDaudio stream tag in the tx_mask. This only works because of the pre-existing order in soc-pcm.c, where the hw_params() is handled for codec_dais *before* cpu_dais. When the order is reversed, the stream_tag is used as a mask in the codec fixup functions:
/* fixup params based on TDM slot masks */ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && codec_dai->tx_mask) soc_pcm_codec_params_fixup(&codec_params, codec_dai->tx_mask);
As a result of this confusion, the codec_params_fixup() ends-up generating bad channel masks, depending on what stream_tag was allocated.
We could add a flag to state that the tx_mask is really not a mask, but it would be quite ugly to persist in overloading concepts.
Instead, this patch suggests a more generic get/set 'stream' API based on the existing model for SoundWire. We can expand the concept to store 'stream' opaque information that is specific to different DAI types. In the case of HDAudio DAIs, we only need to store a stream tag as an unsigned char pointer. The TDM rx_ and tx_masks should really only be used to store masks.
Rename get_sdw_stream/set_sdw_stream callbacks and helpers as get_stream/set_stream. No functionality change beyond the rename.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@intel.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Acked-By: Vinod Koul <vkoul@kernel.org> Link: https://lore.kernel.org/r/20211224021034.26635-5-yung-chuan.liao@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
show more ...
|
#
24f08b3a |
| 13-Jul-2021 |
Bard Liao <yung-chuan.liao@linux.intel.com> |
soundwire: stream: don't program mockup device ports
Mockup devices don't take part in command/control operations and their virtual ports shall not be programmed.
Signed-off-by: Bard Liao <yung-chu
soundwire: stream: don't program mockup device ports
Mockup devices don't take part in command/control operations and their virtual ports shall not be programmed.
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@intel.com> Link: https://lore.kernel.org/r/20210714032209.11284-9-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
show more ...
|
#
e6645314 |
| 13-Jul-2021 |
Bard Liao <yung-chuan.liao@linux.intel.com> |
soundwire: stream: don't abort bank switch on Command_Ignored/-ENODATA
This change is needed for support of mockup devices, which by construction will not provide any answer to a bank switch, but it
soundwire: stream: don't abort bank switch on Command_Ignored/-ENODATA
This change is needed for support of mockup devices, which by construction will not provide any answer to a bank switch, but it's also legit for regular cases.
If for some reason a device loses sync and cannot handle a bank switch, we should go ahead anyways. The devices can always resync later.
The only case where the error flow should be used is when there is a Command_Aborted composite answer from SoundWire devices.
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@intel.com> Link: https://lore.kernel.org/r/20210714032209.11284-6-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
show more ...
|
#
3d3e88e3 |
| 18-Jun-2021 |
Richard Fitzgerald <rf@opensource.cirrus.com> |
soundwire: stream: Fix test for DP prepare complete
In sdw_prep_deprep_slave_ports(), after the wait_for_completion() the DP prepare status register is read. If this indicates that the port is now p
soundwire: stream: Fix test for DP prepare complete
In sdw_prep_deprep_slave_ports(), after the wait_for_completion() the DP prepare status register is read. If this indicates that the port is now prepared, the code should continue with the port setup. It is irrelevant whether the wait_for_completion() timed out if the port is now ready.
The previous implementation would always fail if the wait_for_completion() timed out, even if the port was reporting successful prepare.
This patch also fixes a minor bug where the return from sdw_read() was not checked for error - any error code with LSBits clear could be misinterpreted as a successful port prepare.
Fixes: 79df15b7d37c ("soundwire: Add helpers for ports operations") Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20210618144745.30629-1-rf@opensource.cirrus.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
show more ...
|
#
48f17f96 |
| 30-Mar-2021 |
Rander Wang <rander.wang@intel.com> |
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
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>
show more ...
|
#
53e0a304 |
| 02-Mar-2021 |
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> |
soundwire: stream: remove useless bus initializations
There is no need to assign a pointer to NULL if it's only used in a loop and assigned within that loop.
Signed-off-by: Pierre-Louis Bossart <pi
soundwire: stream: remove useless bus initializations
There is no need to assign a pointer to NULL if it's only used in a loop and assigned within that loop.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@intel.com> Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20210302091122.13952-12-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
show more ...
|
#
5920a29d |
| 02-Mar-2021 |
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> |
soundwire: stream: remove useless initialization
Cppcheck complains about possible null pointer dereferences, but it's more like there are unnecessary initializations before walking through a list.
soundwire: stream: remove useless initialization
Cppcheck complains about possible null pointer dereferences, but it's more like there are unnecessary initializations before walking through a list.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@intel.com> Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20210302091122.13952-11-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
show more ...
|
#
6122d3be |
| 22-Mar-2021 |
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> |
soundwire: stream: add missing \n in dev_err()
We fixed a lot of warnings in 2019 but the magic of copy-paste keeps adding new ones...
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linu
soundwire: stream: add missing \n in dev_err()
We fixed a lot of warnings in 2019 but the magic of copy-paste keeps adding new ones...
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@intel.com> Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20210323005855.20890-5-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
show more ...
|
#
dd87a72a |
| 20-Sep-2020 |
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> |
soundwire: enable Data Port test modes
Test modes are required for all SoundWire IP, and help debug integration issues. In theory each port can be configured with a different mode but to simplify th
soundwire: enable Data Port test modes
Test modes are required for all SoundWire IP, and help debug integration issues. In theory each port can be configured with a different mode but to simplify this patch only offers separate configurations for the Master and Slave ports - this covers 99% of the intended cases during platform integration.
The test mode value is set via platform-specific ways.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@linux.intel.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20200920193207.31241-2-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
show more ...
|
#
9026118f |
| 08-Sep-2020 |
Bard Liao <yung-chuan.liao@linux.intel.com> |
soundwire: Add generic bandwidth allocation algorithm
This algorithm computes bus parameters like clock frequency, frame shape and port transport parameters based on active stream(s) running on the
soundwire: Add generic bandwidth allocation algorithm
This algorithm computes bus parameters like clock frequency, frame shape and port transport parameters based on active stream(s) running on the bus.
Developers can also implement their own .compute_params() callback for specific resource management algorithm, and set if before calling sdw_add_bus_master()
Credits: this patch is based on an earlier internal contribution by Vinod Koul, Sanyog Kale, Shreyas Nc and Hardik Shah. All hard-coded values were removed from the initial contribution to use BIOS information instead.
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Acked-by: Jaroslav Kysela <perex@perex.cz> Link: https://lore.kernel.org/r/20200908131520.5712-1-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
show more ...
|
#
3471d2a1 |
| 03-Sep-2020 |
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> |
soundwire: stream: fix NULL/IS_ERR confusion
snd_soc_dai_get_sdw_stream() can only return -ENOTSUPP or the stream, NULL is not a possible value.
Fixes: 4550569bd779f ('soundwire: stream: add helper
soundwire: stream: fix NULL/IS_ERR confusion
snd_soc_dai_get_sdw_stream() can only return -ENOTSUPP or the stream, NULL is not a possible value.
Fixes: 4550569bd779f ('soundwire: stream: add helper to startup/shutdown streams') Reported-by: Bard Liao <yung-chuan.liao@linux.intel.com> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@linux.intel.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20200903204739.31206-2-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
show more ...
|
#
41ff9174 |
| 03-Sep-2020 |
Vinod Koul <vkoul@kernel.org> |
soundwire: stream: use FIELD_{GET|PREP}
use FIELD_{GET|PREP} in stream code to get/set field values instead of open coding masks and shift operations.
Signed-off-by: Vinod Koul <vkoul@kernel.org> T
soundwire: stream: use FIELD_{GET|PREP}
use FIELD_{GET|PREP} in stream code to get/set field values instead of open coding masks and shift operations.
Signed-off-by: Vinod Koul <vkoul@kernel.org> Tested-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20200903114504.1202143-5-vkoul@kernel.org Signed-off-by: Vinod Koul <vkoul@kernel.org>
show more ...
|
#
063ff4e5 |
| 01-Sep-2020 |
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> |
soundwire: stream: enable hw_sync as needed by hardware
Use platform-specific information to decide when to use hw_sync, not only a number of links > 1.
Signed-off-by: Pierre-Louis Bossart <pierre-
soundwire: stream: enable hw_sync as needed by hardware
Use platform-specific information to decide when to use hw_sync, not only a number of links > 1.
Signed-off-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/20200901150556.19432-8-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
show more ...
|
#
3fbbf214 |
| 02-Sep-2020 |
Tom Rix <trix@redhat.com> |
soundwire: fix double free of dangling pointer
clang static analysis flags this problem
stream.c:844:9: warning: Use of memory after it is freed kfree(bus->defer_msg.msg->buf);
soundwire: fix double free of dangling pointer
clang static analysis flags this problem
stream.c:844:9: warning: Use of memory after it is freed kfree(bus->defer_msg.msg->buf); ^~~~~~~~~~~~~~~~~~~~~~~
This happens in an error handler cleaning up memory allocated for elements in a list.
list_for_each_entry(m_rt, &stream->master_list, stream_node) { bus = m_rt->bus;
kfree(bus->defer_msg.msg->buf); kfree(bus->defer_msg.msg); }
And is triggered when the call to sdw_bank_switch() fails. There are a two problems.
First, when sdw_bank_switch() fails, though it frees memory it does not clear bus's reference 'defer_msg.msg' to that memory.
The second problem is the freeing msg->buf. In some cases msg will be NULL so this will dereference a null pointer. Need to check before freeing.
Fixes: 99b8a5d608a6 ("soundwire: Add bank switch routine") Signed-off-by: Tom Rix <trix@redhat.com> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20200902202650.14189-1-trix@redhat.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
show more ...
|