All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] ALSA: seq: Use no intrruptible mutex_lock
@ 2021-02-01 13:13 Dan Carpenter
  2021-02-01 13:23 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2021-02-01 13:13 UTC (permalink / raw)
  To: tiwai; +Cc: alsa-devel

Hello Takashi Iwai,

The patch 04702e8d0092: "ALSA: seq: Use no intrruptible mutex_lock"
from Aug 1, 2018, leads to the following static checker warning:

	sound/core/seq/seq_clientmgr.c:2194 snd_seq_create_kernel_client()
	warn: called with lock held.  '&register_mutex'

sound/core/seq/seq_midi.c
   294          if (ports > (256 / SNDRV_RAWMIDI_DEVICES))
   295                  ports = 256 / SNDRV_RAWMIDI_DEVICES;
   296  
   297          mutex_lock(&register_mutex);
                           ^^^^^^^^^^^^^^^
Holding lock

   298          client = synths[card->number];
   299          if (client == NULL) {
   300                  newclient = 1;
   301                  client = kzalloc(sizeof(*client), GFP_KERNEL);
   302                  if (client == NULL) {
   303                          mutex_unlock(&register_mutex);
   304                          kfree(info);
   305                          return -ENOMEM;
   306                  }
   307                  client->seq_client =
   308                          snd_seq_create_kernel_client(
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Deadlock

   309                                  card, 0, "%s", card->shortname[0] ?
   310                                  (const char *)card->shortname : "External MIDI");
   311                  if (client->seq_client < 0) {
   312                          kfree(client);
   313                          mutex_unlock(&register_mutex);
   314                          kfree(info);
   315                          return -ENOMEM;
   316                  }
   317          }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [bug report] ALSA: seq: Use no intrruptible mutex_lock
  2021-02-01 13:13 [bug report] ALSA: seq: Use no intrruptible mutex_lock Dan Carpenter
@ 2021-02-01 13:23 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2021-02-01 13:23 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: alsa-devel

On Mon, 01 Feb 2021 14:13:14 +0100,
Dan Carpenter wrote:
> 
> Hello Takashi Iwai,
> 
> The patch 04702e8d0092: "ALSA: seq: Use no intrruptible mutex_lock"
> from Aug 1, 2018, leads to the following static checker warning:
> 
> 	sound/core/seq/seq_clientmgr.c:2194 snd_seq_create_kernel_client()
> 	warn: called with lock held.  '&register_mutex'
> 
> sound/core/seq/seq_midi.c
>    294          if (ports > (256 / SNDRV_RAWMIDI_DEVICES))
>    295                  ports = 256 / SNDRV_RAWMIDI_DEVICES;
>    296  
>    297          mutex_lock(&register_mutex);
>                            ^^^^^^^^^^^^^^^
> Holding lock
> 
>    298          client = synths[card->number];
>    299          if (client == NULL) {
>    300                  newclient = 1;
>    301                  client = kzalloc(sizeof(*client), GFP_KERNEL);
>    302                  if (client == NULL) {
>    303                          mutex_unlock(&register_mutex);
>    304                          kfree(info);
>    305                          return -ENOMEM;
>    306                  }
>    307                  client->seq_client =
>    308                          snd_seq_create_kernel_client(
>                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Deadlock
> 
>    309                                  card, 0, "%s", card->shortname[0] ?
>    310                                  (const char *)card->shortname : "External MIDI");
>    311                  if (client->seq_client < 0) {
>    312                          kfree(client);
>    313                          mutex_unlock(&register_mutex);
>    314                          kfree(info);
>    315                          return -ENOMEM;
>    316                  }
>    317          }

Again, both register_mutex are different instances, where both are
local static variables, hence they can't conflict with each other.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-02-01 13:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-01 13:13 [bug report] ALSA: seq: Use no intrruptible mutex_lock Dan Carpenter
2021-02-01 13:23 ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.