[PATCH] ASoC: core: add snd_BUG_ON() check in devm_snd_soc_register_card()
From: phucduc . bui
Date: Mon Aug 03 2026 - 06:35:09 EST
From: bui duc phuc <phucduc.bui@xxxxxxxxx>
card is dereferenced immediately, so passing NULL results in a NULL
pointer dereference. A NULL dev is silently accepted, defeating the
documented automatic-unregistration semantics of this devm variant.
Add snd_BUG_ON() checks on both arguments to catch API misuse early.
Signed-off-by: bui duc phuc <phucduc.bui@xxxxxxxxx>
---
sound/soc/soc-devres.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/sound/soc/soc-devres.c b/sound/soc/soc-devres.c
index 718165ba84ac..3e946196022a 100644
--- a/sound/soc/soc-devres.c
+++ b/sound/soc/soc-devres.c
@@ -59,6 +59,9 @@ EXPORT_SYMBOL_GPL(devm_snd_soc_register_component);
*/
int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card)
{
+ if (snd_BUG_ON(!dev || !card))
+ return -EINVAL;
+
card->devres_dev = dev;
return snd_soc_register_card(card);
}
--
2.43.0