[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <873488b5uo.wl-tiwai@suse.de>
Date: Sat, 27 Sep 2025 11:30:07 +0200
From: Takashi Iwai <tiwai@...e.de>
To: cryolitia@...ontech.com
Cc: Jaroslav Kysela <perex@...ex.cz>,
Takashi Iwai <tiwai@...e.com>,
Jonathan Corbet <corbet@....net>,
Mingcong Bai <jeffbai@...c.io>,
Kexy Biscuit <kexybiscuit@...c.io>,
Nie Cheng <niecheng1@...ontech.com>,
Zhan Jun <zhanjun@...ontech.com>,
Feng Yuan <fengyuan@...ontech.com>,
qaqland <anguoli@...ontech.com>,
kernel@...ontech.com,
linux-sound@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-doc@...r.kernel.org,
Takashi Iwai <tiwai@...e.de>
Subject: Re: [PATCH v5 2/4] ALSA: usb-audio: improve module param quirk_flags
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
Powered by blists - more mailing lists