Skip to content

Commit 9a0afdd

Browse files
rfvirgilvinodkoul
authored andcommitted
soundwire: stream: sdw_stream_remove_slave(): Check stream is valid
In sdw_stream_remove_slave() check that stream is a valid pointer before passing it to functions that dereference it. Return 0 if the pointer is invalid. This is a convenience for callers. They can safely call this function during cleanup code without needing a pointer validity check duplicated at every call point. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev> Link: https://patch.msgid.link/20260430143353.2702714-1-rf@opensource.cirrus.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 254f496 commit 9a0afdd

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

drivers/soundwire/stream.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2229,11 +2229,15 @@ EXPORT_SYMBOL(sdw_stream_add_slave);
22292229
* @slave: SDW Slave instance
22302230
* @stream: SoundWire stream
22312231
*
2232-
* This removes and frees port_rt and slave_rt from a stream
2232+
* This removes and frees port_rt and slave_rt from a stream.
2233+
* If stream is NULL or an ERR_PTR, do nothing and return 0.
22332234
*/
22342235
int sdw_stream_remove_slave(struct sdw_slave *slave,
22352236
struct sdw_stream_runtime *stream)
22362237
{
2238+
if (IS_ERR_OR_NULL(stream))
2239+
return 0;
2240+
22372241
mutex_lock(&slave->bus->bus_lock);
22382242

22392243
sdw_slave_port_free(slave, stream);

0 commit comments

Comments
 (0)