[PATCH] ALSA: hda: Do not unset preset when cleaning up codec
Cezary Rojewski
cezary.rojewski at intel.com
Wed Jan 18 12:38:15 CET 2023
On 2023-01-17 4:48 PM, Pierre-Louis Bossart wrote:
> On 1/17/23 09:47, Cezary Rojewski wrote:
>> Several functions that take part in codec's initialization and removal
>> are re-used by ASoC codec drivers implementations. Drivers mimic the
>> behavior of hda_codec_driver_probe/remove() found in
>> sound/pci/hda/hda_bind.c with their component->probe/remove() instead.
>>
>> One of the reasons for that is the expectation of
>> snd_hda_codec_device_new() to receive a valid struct snd_card pointer
>> what cannot be fulfilled on ASoC side until a card is attempted to be
>
> very hard to follow.
> Is there a spurious 'what' to be removed?
> Or is there missing text?
> Please consider rewording with simpler sentences.
Thanks for the comments. 'what' is here on purpose as to my ear this
sentence sounds reasonable, but I'm not a native English speaker so I
might be wrong here.
The following is being explained by the commit message:
- functions such as snd_hda_codec_device_new() expect a valid pointer to
struct snd_card instance
- for ASoC hda codec drivers, when hdev_attach/detach() are called,
there is no possibility to provide one to HDAudio API as card components
are not yet enumerated
- once component->probe() is invoked and succeeds, component->card will
point to a valid sound card
- hda codec driver is now ready to call snd_hda_codec_device_new()
>> bound and its component probing is triggered.
>>
>> As ASoC sound card may be unbound without codec device being actually
>> removed from the system, unsetting ->preset in
>> snd_hda_codec_cleanup_for_unbind() interferes with module unload -> load
>> scenario causing null-ptr-deref. Preset is assigned only once, during
>> device/driver matching whereas ASoC codec driver's module reloading may
>> occur several times throughout the lifetime of an audio stack.
>>
>> Signed-off-by: Cezary Rojewski <cezary.rojewski at intel.com>
>> ---
More information about the Alsa-devel
mailing list