Skip to content

Commit 73d38b1

Browse files
committed
[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>
1 parent 20861fa commit 73d38b1

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎sound/core/init.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,12 @@ int snd_card_disconnect(struct snd_card *card)
360360
snd_printk(KERN_ERR "not all devices for card %i can be disconnected\n", card->number);
361361

362362
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
363369
return 0;
364370
}
365371

@@ -401,10 +407,6 @@ static int snd_card_do_free(struct snd_card *card)
401407
snd_printk(KERN_WARNING "unable to free card info\n");
402408
/* Not fatal error */
403409
}
404-
#ifndef CONFIG_SYSFS_DEPRECATED
405-
if (card->card_dev)
406-
device_unregister(card->card_dev);
407-
#endif
408410
kfree(card);
409411
return 0;
410412
}

0 commit comments

Comments
 (0)