Commit 73d38b13ffb105ab633bd91969c8d218b2de38d4

Authored by Takashi Iwai
1 parent 20861fa7b2

[ALSA] Fix the race of card instance unregistration

Move the call of device_unregister() for the card instance in
snd_card_disconnect() to avoid the race of sysfs card entry, which
can be typically found on usb-audio reconnection.

Signed-off-by: Takashi Iwai <tiwai@suse.de>

Showing 1 changed file with 6 additions and 4 deletions Side-by-side Diff

... ... @@ -360,6 +360,12 @@
360 360 snd_printk(KERN_ERR "not all devices for card %i can be disconnected\n", card->number);
361 361  
362 362 snd_info_card_disconnect(card);
  363 +#ifndef CONFIG_SYSFS_DEPRECATED
  364 + if (card->card_dev) {
  365 + device_unregister(card->card_dev);
  366 + card->card_dev = NULL;
  367 + }
  368 +#endif
363 369 return 0;
364 370 }
365 371  
... ... @@ -401,10 +407,6 @@
401 407 snd_printk(KERN_WARNING "unable to free card info\n");
402 408 /* Not fatal error */
403 409 }
404   -#ifndef CONFIG_SYSFS_DEPRECATED
405   - if (card->card_dev)
406   - device_unregister(card->card_dev);
407   -#endif
408 410 kfree(card);
409 411 return 0;
410 412 }