From: Cezary Rojewski <cezary.rojewski@intel.com>
To: Bui Duc Phuc <phucduc.bui@gmail.com>
Cc: <linux-sound@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
"Takashi Iwai" <tiwai@suse.com>, Mark Brown <broonie@kernel.org>,
Jaroslav Kysela <perex@perex.cz>,
Liam Girdwood <lgirdwood@gmail.com>
Subject: Re: [PATCH] ASoC: core: add snd_BUG_ON() check in devm_snd_soc_register_card()
Date: Mon, 3 Aug 2026 22:42:40 +0200 [thread overview]
Message-ID: <61910d04-6f6c-4c99-bc96-397163cfc31f@intel.com> (raw)
In-Reply-To: <CAABR9nHynGR4TjdpGW9-sjEC8p1x4D8omq8ouPR6E-3ifDhBqw@mail.gmail.com>
On 8/3/2026 1:58 PM, Bui Duc Phuc wrote:
>> Not sure whether we need such defenses. If we are to follow such
>> approach, many ASoC-driver APIs require BUG_ON/WARN_ON() update.
>>
>> register_card() is typically called as a last step, once 'card' is
>> already allocated. At the same time, the register_card() typically
>> occurs in probe() context of given device so we're always certain the
>> 'dev' is not NULL.
>>
>> TLDR: this is not a UAPI, (obvious) NULL-checks can be skipped.
>
> I completely understand where you're coming from.
> My thinking was that this function is referenced quite widely
> (currently in 112 files).
> Given how frequently it is used, I felt that adding a simple defensive
> check here
> could make the API a little more robust and help avoid potential
> NULL pointer dereferences for both existing and future callers.
>
> I wasn't suggesting that every ASoC API should be updated this way.
> I was only thinking of APIs that are used very frequently, especially
> those commonly called from probe paths.
>
> Also, it's not always obvious to callers what assumptions a core API
> relies on or
> the context in which it is expected to be used.
>
> That was simply the motivation behind this patch.
snd_BUG_ON() translates to WARN_ON() in debug conditions. After reading
the macro documentation, pr_xxx() or equivalents are recommended when
dealing with invalid arguments. Same results after grepping for WARNs
in sound/soc or in general references such as driver/base/core.c - it's
clear to me the macro is not used as plain null-arg-check.
Updating just one function with the check raises the question when
reading the file - Why just one devm_snd_xxx() has the check and the
rest do not?
Kind regards,
Czarek
next prev parent reply other threads:[~2026-08-03 20:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 10:27 phucduc.bui
2026-08-03 10:50 ` Cezary Rojewski
2026-08-03 11:58 ` Bui Duc Phuc
2026-08-03 20:42 ` Cezary Rojewski [this message]
2026-08-04 3:19 ` Bui Duc Phuc
2026-08-04 11:27 ` Cezary Rojewski
2026-08-04 14:02 ` Bui Duc Phuc
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=61910d04-6f6c-4c99-bc96-397163cfc31f@intel.com \
--to=cezary.rojewski@intel.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=phucduc.bui@gmail.com \
--cc=tiwai@suse.com \
/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
all inboxes | Powered by JetHome®