[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <07e228eb-676a-bdb1-c2ec-a96f691f5a18@linaro.org>
Date: Wed, 17 Nov 2021 13:56:14 -0600
From: Alex Elder <elder@...aro.org>
To: Takashi Iwai <tiwai@...e.de>, greybus-dev@...ts.linaro.org
Cc: Alex Elder <elder@...nel.org>, Johan Hovold <johan@...nel.org>,
linux-kernel@...r.kernel.org
Subject: Re: [greybus-dev] [PATCH] staging: greybus: Add missing rwsem around
snd_ctl_remove() calls
On 11/16/21 1:20 AM, Takashi Iwai wrote:
> snd_ctl_remove() has to be called with card->controls_rwsem held (when
> called after the card instantiation). This patch adds the missing
> rwsem calls around it.
I see the comment above snd_ctl_remove() that says you must hold
the write lock. And given that, this seems correct to me.
I understand why you want to take the lock just once, rather
than each time snd_ctl_remove() is called.
However I believe the acquisition and release of the lock
belongs inside gbaudio_remove_controls(), not in its caller.
If you disagree, can you please explain why?
Otherwise, will you please submit version two, taking the
lock inside gbaudio_remove_controls()?
Thanks.
-Alex
> Fixes: 510e340efe0c ("staging: greybus: audio: Add helper APIs for dynamic audio modules")
> Signed-off-by: Takashi Iwai <tiwai@...e.de>
> ---
> drivers/staging/greybus/audio_helper.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/greybus/audio_helper.c b/drivers/staging/greybus/audio_helper.c
> index 1ed4772d2771..843760675876 100644
> --- a/drivers/staging/greybus/audio_helper.c
> +++ b/drivers/staging/greybus/audio_helper.c
> @@ -192,7 +192,11 @@ int gbaudio_remove_component_controls(struct snd_soc_component *component,
> unsigned int num_controls)
> {
> struct snd_card *card = component->card->snd_card;
> + int err;
>
> - return gbaudio_remove_controls(card, component->dev, controls,
> - num_controls, component->name_prefix);
> + down_write(&card->controls_rwsem);
> + err = gbaudio_remove_controls(card, component->dev, controls,
> + num_controls, component->name_prefix);
> + up_write(&card->controls_rwsem);
> + return err;
> }
>
Powered by blists - more mailing lists