From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.de>,
alsa-devel@alsa-project.org, Mark Brown <broonie@kernel.org>
Subject: Re: [PATCH] ALSA: core: Warn on empty module
Date: Wed, 24 Jun 2020 12:06:59 -0500 [thread overview]
Message-ID: <812d664c-f143-5c42-8eeb-95fd5f5266b3@linux.intel.com> (raw)
In-Reply-To: <6e04386e-d5f7-7e59-3641-13b551de9392@perex.cz>
On 6/24/20 11:33 AM, Jaroslav Kysela wrote:
> Dne 24. 06. 20 v 18:13 Pierre-Louis Bossart napsal(a):
>>
>>
>> On 6/24/20 11:03 AM, Takashi Iwai wrote:
>>> 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.
>>>
>>> Signed-off-by: Takashi Iwai <tiwai@suse.de>
>>> ---
>>> sound/core/init.c | 3 +++
>>> 1 file changed, 3 insertions(+)
>>>
>>> diff --git a/sound/core/init.c b/sound/core/init.c
>>> index b02a99766351..0478847ba2b8 100644
>>> --- a/sound/core/init.c
>>> +++ b/sound/core/init.c
>>> @@ -203,7 +203,10 @@ int snd_card_new(struct device *parent, int idx,
>>> const char *xid,
>>> mutex_unlock(&snd_card_mutex);
>>> card->dev = parent;
>>> card->number = idx;
>>> +#ifdef MODULE
>>> + WARN_ON(!module);
>>> card->module = module;
>>> +#endif
>>> INIT_LIST_HEAD(&card->devices);
>>> init_rwsem(&card->controls_rwsem);
>>> rwlock_init(&card->ctl_files_rwlock);
>>
>> Would it make sense to also change the ASoC code to use THIS_MODULE
>> instead of card->owner?
>>
>> /* card bind complete so register a sound card */
>> ret = snd_card_new(card->dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
>> card->owner, 0, &card->snd_card);
>>
>> A quick grep shows we are setting .owner = THIS_MODULE pretty much all
>> the time for machine drivers.
>>
>
> THIS_MODULE is defined when the object file is created (compile time).
> We want to assign the real module which creates the card here, not
> "snd_soc_core" which is misleading.
ok, will submit fixes for the Intel cards where this is missing.
Thanks Jaroslav for reporting this and Takashi for identifying the issue.
next prev parent reply other threads:[~2020-06-24 17:08 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20200630123043eucas1p2f95aa10ad1611e902269fbf9b783c405@eucas1p2.samsung.com>
2020-06-24 16:03 ` [PATCH] ALSA: core: Warn on empty module Takashi Iwai
2020-06-24 16:13 ` Pierre-Louis Bossart
2020-06-24 16:33 ` Jaroslav Kysela
2020-06-24 17:06 ` Pierre-Louis Bossart [this message]
2020-06-24 17:35 ` Takashi Iwai
2020-06-30 12:30 ` Marek Szyprowski
2020-06-30 12:34 ` Nicolas Saenz Julienne
2020-06-30 12:36 ` Marek Szyprowski
2020-06-30 12:38 ` Nicolas Saenz Julienne
2020-06-30 17:40 ` Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=812d664c-f143-5c42-8eeb-95fd5f5266b3@linux.intel.com \
--to=pierre-louis.bossart@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox