[PATCH] soundwire: stream: add s_rt into slave_rt_list before sdw_config_stream

Dongliang Mu mudongliangabcd at gmail.com
Thu Jul 22 13:24:16 CEST 2021


On Thu, Jul 22, 2021 at 7:17 PM Dan Carpenter <dan.carpenter at oracle.com> wrote:
>
> On Thu, Jul 22, 2021 at 06:56:11PM +0800, Dongliang Mu wrote:
> > The commit 48f17f96a817 ("soundwire: stream: fix memory leak in stream
> > config error path") fixes the memory leak by implicitly freeing the s_rt
> > object. However, this fixing style is not very good.
> >
> > The better fix is to move list_add_tail before sdw_config_stream and
> > revert the previous commit.
> >
> > Signed-off-by: Dongliang Mu <mudongliangabcd at gmail.com>
> > ---
> >  drivers/soundwire/stream.c | 14 +++-----------
> >  1 file changed, 3 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c
> > index 1a18308f4ef4..66a4ce4f923f 100644
> > --- a/drivers/soundwire/stream.c
> > +++ b/drivers/soundwire/stream.c
> > @@ -1373,19 +1373,11 @@ int sdw_stream_add_slave(struct sdw_slave *slave,
> >               goto stream_error;
> >       }
> >
> > +     list_add_tail(&s_rt->m_rt_node, &m_rt->slave_rt_list);
> > +
> >       ret = sdw_config_stream(&slave->dev, stream, stream_config, true);
>
> There some sanity checks on the stream inside sdw_config_stream() so
> that's probably why we didn't add it until later.  (I don't know the
> code well, but that's what I would suspect from a glance).

I think those sanity checks are not much related to list_add_tail.

Except that, do you have other concerns?

I think this patch could improve the readability of code, so I submit
this patch to the mailing list. But I am not sure if the community
favors this kind of patch.

>
> regards,
> dan carpenter
>


More information about the Alsa-devel mailing list