All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: cryolitia@uniontech.com
Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	Jonathan Corbet <corbet@lwn.net>, Mingcong Bai <jeffbai@aosc.io>,
	Kexy Biscuit <kexybiscuit@aosc.io>,
	Nie Cheng <niecheng1@uniontech.com>,
	Zhan Jun <zhanjun@uniontech.com>,
	Feng Yuan <fengyuan@uniontech.com>,
	qaqland <anguoli@uniontech.com>,
	kernel@uniontech.com, linux-sound@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	Takashi Iwai <tiwai@suse.de>
Subject: Re: [PATCH v5 2/4] ALSA: usb-audio: improve module param quirk_flags
Date: Sat, 27 Sep 2025 11:30:07 +0200	[thread overview]
Message-ID: <873488b5uo.wl-tiwai@suse.de> (raw)
In-Reply-To: <20250925-sound-v5-2-2593586ff350@uniontech.com>

On Thu, 25 Sep 2025 11:25:17 +0200,
Cryolitia PukNgae via B4 Relay wrote:
> +static void snd_usb_init_quirk_flags(int idx, struct snd_usb_audio *chip)
> +{
> +	/* add or correct quirk bits from options */
> +	for (i = 0; i < ARRAY_SIZE(quirk_flags); i++) {
> +		if (!quirk_flags[i] || !*quirk_flags[i])
> +			break;
> +
> +		val = kstrdup(quirk_flags[i], GFP_KERNEL);
> +
> +		if (!val)
> +			return;
> +
> +		snd_usb_init_quirk_flags_parse_string(chip, val);
> +
> +		kfree(val);

For a temporary string allocation, nowadays it's better to use
__free(kfree):

	for (i = 0; i < ARRAY_SIZE(quirk_flags); i++) {
		if (!quirk_flags[i] || !*quirk_flags[i])
			break;

		char *val __free(kfree) = 
			kstrdup(quirk_flags[i], GFP_KERNEL);
		if (!val)
			return;

		snd_usb_init_quirk_flags_parse_string(chip, val);
	}

Or maybe it's even safer to pass the original string (with const) and
do kstrdup() in the callee side.  You can use __free(kfree) in the
same way in snd_usb_init_quirk_flags_parse_string().


thanks,

Takashi

  reply	other threads:[~2025-09-27  9:30 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-25  9:25 [PATCH v5 0/4] ALSA: usb-audio: improve module param quirk_flags Cryolitia PukNgae
2025-09-25  9:25 ` Cryolitia PukNgae via B4 Relay
2025-09-25  9:25 ` [PATCH v5 1/4] ALSA: usb-audio: add two-way convert between name and bit for QUIRK_FLAG_* Cryolitia PukNgae
2025-09-25  9:25   ` Cryolitia PukNgae via B4 Relay
2025-09-27  9:24   ` Takashi Iwai
2025-09-25  9:25 ` [PATCH v5 2/4] ALSA: usb-audio: improve module param quirk_flags Cryolitia PukNgae
2025-09-25  9:25   ` Cryolitia PukNgae via B4 Relay
2025-09-27  9:30   ` Takashi Iwai [this message]
2025-09-25  9:25 ` [PATCH v5 3/4] ALSA: usb-audio: make param quirk_flags change-able in runtime Cryolitia PukNgae
2025-09-25  9:25   ` Cryolitia PukNgae via B4 Relay
2025-09-27  9:32   ` Takashi Iwai
2025-09-27 11:13   ` kernel test robot
2025-09-25  9:25 ` [PATCH v5 4/4] ALSA: doc: add docs about improved quirk_flags in snd-usb-audio Cryolitia PukNgae
2025-09-25  9:25   ` Cryolitia PukNgae via B4 Relay
2025-09-27  9:21 ` [PATCH v5 0/4] ALSA: usb-audio: improve module param quirk_flags 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=873488b5uo.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=anguoli@uniontech.com \
    --cc=corbet@lwn.net \
    --cc=cryolitia@uniontech.com \
    --cc=fengyuan@uniontech.com \
    --cc=jeffbai@aosc.io \
    --cc=kernel@uniontech.com \
    --cc=kexybiscuit@aosc.io \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=niecheng1@uniontech.com \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    --cc=zhanjun@uniontech.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.