From: Richard Fitzgerald <rf@opensource.cirrus.com>
To: Shuhao Fu <sfual@cse.ust.hk>, David Rhodes <david.rhodes@cirrus.com>
Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
linux-sound@vger.kernel.org, patches@opensource.cirrus.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] ALSA: hda: cs35l56: Put ACPI device after setting companion
Date: Tue, 28 Apr 2026 10:05:26 +0100 [thread overview]
Message-ID: <ade87b5f-ee9a-4007-9b06-30bfc9561822@opensource.cirrus.com> (raw)
In-Reply-To: <20260428080139.GA1649104@chcpu16>
On 28/04/2026 9:01 am, Shuhao Fu wrote:
> acpi_dev_get_first_match_dev() returns a refcounted ACPI device and
> callers are expected to balance it with acpi_dev_put().
>
> When no companion is already attached, cs35l56_hda_read_acpi() looks
> up an ACPI device and sets it with ACPI_COMPANION_SET(), but leaves
> the lookup reference held.
>
> ACPI_COMPANION_SET() does not take ownership of that reference, so
> drop it with acpi_dev_put() after attaching the companion.
Are you sure about this?
I remember when I wrote this code I checked the driver core and saw that
if there is a companion it puts it when the driver is removed.
That is why I didn't put the reference here, it would have caused a
double put.
>
> Fixes: 73cfbfa9caea ("ALSA: hda/cs35l56: Add driver for Cirrus Logic CS35L56 amplifier")
> Signed-off-by: Shuhao Fu <sfual@cse.ust.hk>
> ---
> sound/hda/codecs/side-codecs/cs35l56_hda.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/sound/hda/codecs/side-codecs/cs35l56_hda.c b/sound/hda/codecs/side-codecs/cs35l56_hda.c
> index 1ace4beef50857b..16a5a40899b2873 100644
> --- a/sound/hda/codecs/side-codecs/cs35l56_hda.c
> +++ b/sound/hda/codecs/side-codecs/cs35l56_hda.c
> @@ -1032,6 +1032,7 @@ static int cs35l56_hda_read_acpi(struct cs35l56_hda *cs35l56, int hid, int id)
> return -ENODEV;
> }
> ACPI_COMPANION_SET(cs35l56->base.dev, adev);
> + acpi_dev_put(adev);
> }
>
> /* Initialize things that could be overwritten by a fixup */
next prev parent reply other threads:[~2026-04-28 9:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-28 7:44 [PATCH 0/2] ALSA: hda: Fix Cirrus ACPI device reference leaks Shuhao Fu
2026-04-28 8:01 ` [PATCH 1/2] ALSA: hda: cs35l56: Put ACPI device after setting companion Shuhao Fu
2026-04-28 9:05 ` Richard Fitzgerald [this message]
2026-04-28 8:12 ` [PATCH 2/2] ALSA: hda: cs35l41: Put ACPI device on missing physical node Shuhao Fu
2026-04-28 10:40 ` [PATCH 1/2] ALSA: hda: cs35l56: Put ACPI device after setting companion Shuhao Fu
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=ade87b5f-ee9a-4007-9b06-30bfc9561822@opensource.cirrus.com \
--to=rf@opensource.cirrus.com \
--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=sfual@cse.ust.hk \
--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