Re: [PATCH v2 03/10] soundwire: stream: Prevent m_rt_count underflow in sdw_stream_remove_master()

From: Charles Keepax

Date: Fri Nov 13 2026 - 15:23:56 EST


On Tue, Nov 03, 2026 at 09:53:47AM +0000, Lee Jones wrote:
> stream->m_rt_count is incremented in sdw_stream_add_master() after
> sdw_master_port_alloc() succeeds. However, sdw_stream_add_slave() can
> allocate a master runtime without allocating master ports, and
> sdw_master_port_alloc() can fail after partially populating
> m_rt->port_list. When sdw_stream_remove_master() subsequently tears
> down the stream, it unconditionally decrements stream->m_rt_count,
> underflowing the counter when master ports were never allocated.
>
> Free any partially allocated master ports on allocation failure in
> sdw_master_port_alloc(), and only increment and decrement
> stream->m_rt_count when master ports are allocated.
>
> Closes: https://sashiko.dev/#/bug/linux-bce288e6-c97f-46dd-9fc3-023c33d56f36
> Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
> ---

Reviewed-by: Charles Keepax <ckeepax@xxxxxxxxxxxxxxxxxxxxx>

Thanks,
Charles