mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-24 04:34:08 +08:00
ALSA: core: Warn on empty module
The module argument passed to snd_card_new() must be a valid non-NULL pointer when the module support is enabled. Since ASoC driver passes the argument from each snd_soc_card definition, one may forget to set the owner field and lead to a NULL module easily. For catching such an overlook, add a WARN_ON() in snd_card_new(). Also, put the card->module assignment in the ifdef block for a very minor optimization. Link: https://lore.kernel.org/r/20200624160300.21703-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
c7440acc85
commit
81033c6b58
@ -203,7 +203,10 @@ int snd_card_new(struct device *parent, int idx, const char *xid,
|
|||||||
mutex_unlock(&snd_card_mutex);
|
mutex_unlock(&snd_card_mutex);
|
||||||
card->dev = parent;
|
card->dev = parent;
|
||||||
card->number = idx;
|
card->number = idx;
|
||||||
|
#ifdef MODULE
|
||||||
|
WARN_ON(!module);
|
||||||
card->module = module;
|
card->module = module;
|
||||||
|
#endif
|
||||||
INIT_LIST_HEAD(&card->devices);
|
INIT_LIST_HEAD(&card->devices);
|
||||||
init_rwsem(&card->controls_rwsem);
|
init_rwsem(&card->controls_rwsem);
|
||||||
rwlock_init(&card->ctl_files_rwlock);
|
rwlock_init(&card->ctl_files_rwlock);
|
||||||
|
Loading…
Reference in New Issue
Block a user