[PATCH] ASoC: core: add snd_BUG_ON() check in devm_snd_soc_register_card()
[email protected] Mon, 3 Aug 2026 17:27:39 +0700
| Newsgroups | gmane.linux.kernel,gmane.linux.sound |
|---|---|
| Message-ID | <[email protected]> |
From: bui duc phuc <[email protected]> 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 <[email protected]> --- 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