mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-05 00:20:32 +00:00
ALSA: core: Make snd_card_disconnect() return void
All callers from other files ignore the return value of this function. And it can only ever return a non-zero value if the parameter card is NULL. Move the check for card being NULL into snd_card_free_when_closed() to keep the previous behaviour. Note this isn't necessary for snd_card_disconnect_sync() because if card was NULL in there the dereference of card for dev_err() would oops the kernel. Replace this by an oops triggered by the dereference of card for spin_lock_irq(). Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Jaroslav Kysela <perex@perex.cz> Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Acked-by: Geoff Levand <geoff@infradead.org> Acked-by: Thierry Reding <treding@nvidia.com> Link: https://lore.kernel.org/r/20230207191907.467756-2-u.kleine-koenig@pengutronix.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
69218b59be
commit
663f922fd7
2 changed files with 9 additions and 17 deletions
|
@ -286,7 +286,7 @@ int snd_devm_card_new(struct device *parent, int idx, const char *xid,
|
||||||
struct module *module, size_t extra_size,
|
struct module *module, size_t extra_size,
|
||||||
struct snd_card **card_ret);
|
struct snd_card **card_ret);
|
||||||
|
|
||||||
int snd_card_disconnect(struct snd_card *card);
|
void snd_card_disconnect(struct snd_card *card);
|
||||||
void snd_card_disconnect_sync(struct snd_card *card);
|
void snd_card_disconnect_sync(struct snd_card *card);
|
||||||
int snd_card_free(struct snd_card *card);
|
int snd_card_free(struct snd_card *card);
|
||||||
int snd_card_free_when_closed(struct snd_card *card);
|
int snd_card_free_when_closed(struct snd_card *card);
|
||||||
|
|
|
@ -489,17 +489,17 @@ static const struct file_operations snd_shutdown_f_ops =
|
||||||
* Note: The current implementation replaces all active file->f_op with special
|
* Note: The current implementation replaces all active file->f_op with special
|
||||||
* dummy file operations (they do nothing except release).
|
* dummy file operations (they do nothing except release).
|
||||||
*/
|
*/
|
||||||
int snd_card_disconnect(struct snd_card *card)
|
void snd_card_disconnect(struct snd_card *card)
|
||||||
{
|
{
|
||||||
struct snd_monitor_file *mfile;
|
struct snd_monitor_file *mfile;
|
||||||
|
|
||||||
if (!card)
|
if (!card)
|
||||||
return -EINVAL;
|
return;
|
||||||
|
|
||||||
spin_lock(&card->files_lock);
|
spin_lock(&card->files_lock);
|
||||||
if (card->shutdown) {
|
if (card->shutdown) {
|
||||||
spin_unlock(&card->files_lock);
|
spin_unlock(&card->files_lock);
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
card->shutdown = 1;
|
card->shutdown = 1;
|
||||||
|
|
||||||
|
@ -548,7 +548,6 @@ int snd_card_disconnect(struct snd_card *card)
|
||||||
wake_up(&card->power_sleep);
|
wake_up(&card->power_sleep);
|
||||||
snd_power_sync_ref(card);
|
snd_power_sync_ref(card);
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(snd_card_disconnect);
|
EXPORT_SYMBOL(snd_card_disconnect);
|
||||||
|
|
||||||
|
@ -563,15 +562,7 @@ EXPORT_SYMBOL(snd_card_disconnect);
|
||||||
*/
|
*/
|
||||||
void snd_card_disconnect_sync(struct snd_card *card)
|
void snd_card_disconnect_sync(struct snd_card *card)
|
||||||
{
|
{
|
||||||
int err;
|
snd_card_disconnect(card);
|
||||||
|
|
||||||
err = snd_card_disconnect(card);
|
|
||||||
if (err < 0) {
|
|
||||||
dev_err(card->dev,
|
|
||||||
"snd_card_disconnect error (%d), skipping sync\n",
|
|
||||||
err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
spin_lock_irq(&card->files_lock);
|
spin_lock_irq(&card->files_lock);
|
||||||
wait_event_lock_irq(card->remove_sleep,
|
wait_event_lock_irq(card->remove_sleep,
|
||||||
|
@ -619,9 +610,10 @@ static int snd_card_do_free(struct snd_card *card)
|
||||||
*/
|
*/
|
||||||
int snd_card_free_when_closed(struct snd_card *card)
|
int snd_card_free_when_closed(struct snd_card *card)
|
||||||
{
|
{
|
||||||
int ret = snd_card_disconnect(card);
|
if (!card)
|
||||||
if (ret)
|
return -EINVAL;
|
||||||
return ret;
|
|
||||||
|
snd_card_disconnect(card);
|
||||||
put_device(&card->card_dev);
|
put_device(&card->card_dev);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue