From: Mark Brown <broonie@kernel.org>
To: Guangshuo Li <lgs201920130244@gmail.com>
Cc: Kiseok Jo <kiseok.jo@irondevice.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Chenyuan Yang <chenyuan0y@gmail.com>,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] ASoC: sma1307: fix double free of devm_kzalloc() memory
Date: Thu, 12 Mar 2026 12:06:28 +0000 [thread overview]
Message-ID: <4e7e5bfb-2497-4b6e-91b2-871d2c4eee92@sirena.org.uk> (raw)
In-Reply-To: <20260312084749.365325-1-lgs201920130244@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 788 bytes --]
On Thu, Mar 12, 2026 at 04:47:49PM +0800, Guangshuo Li wrote:
> A previous change added NULL checks and cleanup for allocation
> failures in sma1307_setting_loaded().
>
> However, the cleanup for mode_set entries is wrong. Those entries are
> allocated with devm_kzalloc(), so they are device-managed resources and
> must not be freed with kfree(). Manually freeing them in the error path
> can lead to a double free when devres later releases the same memory.
>
> Drop the manual kfree() loop and let devres handle the cleanup.
You're right that we shouldn't be using kfree() here, however the
settings can be reloaded via the userpace visible reset control the
driver has so removing the free entirely will leake the mode strings.
We need a devm_kfree() here I think.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2026-03-12 12:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-12 8:47 Guangshuo Li
2026-03-12 12:06 ` Mark Brown [this message]
2026-03-16 17:52 ` Mark Brown
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=4e7e5bfb-2497-4b6e-91b2-871d2c4eee92@sirena.org.uk \
--to=broonie@kernel.org \
--cc=chenyuan0y@gmail.com \
--cc=kiseok.jo@irondevice.com \
--cc=lgirdwood@gmail.com \
--cc=lgs201920130244@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=stable@vger.kernel.org \
--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®