mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Cássio Gabriel Monteiro Pires" <cassiogabrielcontato@gmail.com>
To: Richard Fitzgerald <rf@opensource.cirrus.com>,
	David Rhodes <david.rhodes@cirrus.com>,
	Takashi Iwai <tiwai@suse.com>, Jaroslav Kysela <perex@perex.cz>,
	Simon Trimmer <simont@opensource.cirrus.com>,
	Mark Brown <broonie@kernel.org>
Cc: linux-sound@vger.kernel.org, patches@opensource.cirrus.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] ALSA: hda: cs35l56: Free ACPI _SUB string on errors
Date: Thu, 21 May 2026 09:48:44 -0300	[thread overview]
Message-ID: <e68491b9-2274-4cba-982a-02516cdd5e51@gmail.com> (raw)
In-Reply-To: <243581c7-8b17-4415-bd8b-bc8fc4560f1f@opensource.cirrus.com>


[-- Attachment #1.1: Type: text/plain, Size: 1210 bytes --]

On 5/21/26 09:14, Richard Fitzgerald wrote:
>>   -    sub = acpi_get_subsystem_id(ACPI_HANDLE(cs35l56->base.dev));
>> +    const char *sub __free(kfree) = acpi_get_subsystem_id(ACPI_HANDLE(cs35l56->base.dev));
>> +    const char *system_name __free(kfree) = NULL;
>> +
> 
> Initializing a __free(kfree) to NULL is controversial. The kerneldoc
> warns against it. Though I think your code is totally fine it might be
> best to avoid.

I used __free(kfree) for the derived system_name to keep
ownership transfer local until read_acpi() had passed the reset GPIO error
path, but I agree that initializing a cleanup variable to NULL is best
avoided.

> 
> I can't see any reason why we didn't use devm cleanup for
> cs35l56->system_name.
> 
> So
> 
>            if (ret == -ENOENT) {
>             cs35l56->system_name = devm_kstrdup(dev, sub,
> GFP_KERNEL);
>           } else if (ret >= 0) {
>             cs35l56->system_name = devm_kasprintf(dev, ...);
>             ...
> 
> 
> and delete the manual kfree(cs35l56->system_name) in
> cs35l56_hda_remove(). 

I'll send a v3 with that approach.


Thanks,
Cássio

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

  reply	other threads:[~2026-05-21 12:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-20 14:50 [PATCH v2 0/2] ALSA: hda: cs35l56: fix system name leaks Cássio Gabriel
2026-05-20 14:50 ` [PATCH v2 1/2] ALSA: hda: cs35l56: Free ACPI _SUB string on errors Cássio Gabriel
2026-05-21 12:14   ` Richard Fitzgerald
2026-05-21 12:48     ` Cássio Gabriel Monteiro Pires [this message]
2026-05-20 14:50 ` [PATCH v2 2/2] ALSA: hda: cs35l56: Free system name on probe errors Cássio Gabriel

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=e68491b9-2274-4cba-982a-02516cdd5e51@gmail.com \
    --to=cassiogabrielcontato@gmail.com \
    --cc=broonie@kernel.org \
    --cc=david.rhodes@cirrus.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    --cc=perex@perex.cz \
    --cc=rf@opensource.cirrus.com \
    --cc=simont@opensource.cirrus.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®