* [PATCH] soundwire: stream: sdw_stream_remove_slave(): Check stream is valid
@ 2026-04-30 14:33 Richard Fitzgerald
2026-04-30 20:01 ` Pierre-Louis Bossart
2026-05-03 16:33 ` Vinod Koul
0 siblings, 2 replies; 3+ messages in thread
From: Richard Fitzgerald @ 2026-04-30 14:33 UTC (permalink / raw)
To: vkoul, yung-chuan.liao, pierre-louis.bossart
Cc: linux-sound, linux-kernel, patches
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>
---
drivers/soundwire/stream.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c
index 4ed8fb7663ad..c1ef177a0021 100644
--- a/drivers/soundwire/stream.c
+++ b/drivers/soundwire/stream.c
@@ -2229,11 +2229,15 @@ EXPORT_SYMBOL(sdw_stream_add_slave);
* @slave: SDW Slave instance
* @stream: SoundWire stream
*
- * This removes and frees port_rt and slave_rt from a stream
+ * This removes and frees port_rt and slave_rt from a stream.
+ * If stream is NULL or an ERR_PTR, do nothing and return 0.
*/
int sdw_stream_remove_slave(struct sdw_slave *slave,
struct sdw_stream_runtime *stream)
{
+ if (IS_ERR_OR_NULL(stream))
+ return 0;
+
mutex_lock(&slave->bus->bus_lock);
sdw_slave_port_free(slave, stream);
--
2.47.3
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] soundwire: stream: sdw_stream_remove_slave(): Check stream is valid
2026-04-30 14:33 [PATCH] soundwire: stream: sdw_stream_remove_slave(): Check stream is valid Richard Fitzgerald
@ 2026-04-30 20:01 ` Pierre-Louis Bossart
2026-05-03 16:33 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Pierre-Louis Bossart @ 2026-04-30 20:01 UTC (permalink / raw)
To: Richard Fitzgerald, vkoul, yung-chuan.liao
Cc: linux-sound, linux-kernel, patches
On 4/30/26 16:33, Richard Fitzgerald wrote:
> 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>
LGTM
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
> ---
> drivers/soundwire/stream.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c
> index 4ed8fb7663ad..c1ef177a0021 100644
> --- a/drivers/soundwire/stream.c
> +++ b/drivers/soundwire/stream.c
> @@ -2229,11 +2229,15 @@ EXPORT_SYMBOL(sdw_stream_add_slave);
> * @slave: SDW Slave instance
> * @stream: SoundWire stream
> *
> - * This removes and frees port_rt and slave_rt from a stream
> + * This removes and frees port_rt and slave_rt from a stream.
> + * If stream is NULL or an ERR_PTR, do nothing and return 0.
> */
> int sdw_stream_remove_slave(struct sdw_slave *slave,
> struct sdw_stream_runtime *stream)
> {
> + if (IS_ERR_OR_NULL(stream))
> + return 0;
> +
> mutex_lock(&slave->bus->bus_lock);
>
> sdw_slave_port_free(slave, stream);
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] soundwire: stream: sdw_stream_remove_slave(): Check stream is valid
2026-04-30 14:33 [PATCH] soundwire: stream: sdw_stream_remove_slave(): Check stream is valid Richard Fitzgerald
2026-04-30 20:01 ` Pierre-Louis Bossart
@ 2026-05-03 16:33 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2026-05-03 16:33 UTC (permalink / raw)
To: yung-chuan.liao, pierre-louis.bossart, Richard Fitzgerald
Cc: linux-sound, linux-kernel, patches
On Thu, 30 Apr 2026 15:33:53 +0100, Richard Fitzgerald wrote:
> 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.
>
> [...]
Applied, thanks!
[1/1] soundwire: stream: sdw_stream_remove_slave(): Check stream is valid
commit: 9a0afdd19a01c6edddb92eb6a464f9e99d946b90
Best regards,
--
~Vinod
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-03 16:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-30 14:33 [PATCH] soundwire: stream: sdw_stream_remove_slave(): Check stream is valid Richard Fitzgerald
2026-04-30 20:01 ` Pierre-Louis Bossart
2026-05-03 16:33 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox