Skip to content

Commit 81033c6

Browse files
committed
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>
1 parent c7440ac commit 81033c6

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎sound/core/init.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,10 @@ int snd_card_new(struct device *parent, int idx, const char *xid,
203203
mutex_unlock(&snd_card_mutex);
204204
card->dev = parent;
205205
card->number = idx;
206+
#ifdef MODULE
207+
WARN_ON(!module);
206208
card->module = module;
209+
#endif
207210
INIT_LIST_HEAD(&card->devices);
208211
init_rwsem(&card->controls_rwsem);
209212
rwlock_init(&card->ctl_files_rwlock);

0 commit comments

Comments
 (0)