public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Georgi Djakov <djakov@kernel.org>
To: Gui-Dong Han <hanguidong02@gmail.com>
Cc: Kuan-Wei Chiu <visitorckw@gmail.com>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	akaieurus@gmail.com, me@ziyao.cc
Subject: Re: [PATCH] interconnect: debugfs: fix devm_kstrdup and kfree mismatch
Date: Thu, 2 Apr 2026 19:00:34 +0300	[thread overview]
Message-ID: <01a921b7-4b8d-4df6-9840-300a8c143e71@kernel.org> (raw)
In-Reply-To: <CALbr=LYyNh0AwC+8ni6iS=9UiTyVz9+r_gM7M=ohacCv97ujOw@mail.gmail.com>

On 4/2/26 6:42 PM, Gui-Dong Han wrote:
> On Wed, Mar 18, 2026 at 10:48 AM Gui-Dong Han <hanguidong02@gmail.com> wrote:
>>
>> debugfs_write_file_str() uses standard kfree() to release old strings.
>> Initializing src_node and dst_node with devm_kstrdup() creates a memory
>> management mismatch. If a user writes to these debugfs nodes, the
>> devm-allocated memory is freed via kfree(), leaving a dangling pointer
>> in the device resource list that can lead to a double free.
>>
>> Fix this by using standard kstrdup() instead. Since the interconnect
>> subsystem is strictly built-in and cannot be unloaded as a module, there
>> is no exit path requiring manual cleanup of these strings. The error
>> handling path is also simplified by taking advantage of the fact that
>> kfree(NULL) is a safe no-op.
>>
>> Fixes: 8cc27f5c6dd1 ("interconnect: debugfs: initialize src_node and dst_node to empty strings")
>> Signed-off-by: Gui-Dong Han <hanguidong02@gmail.com>
>> ---
>> I noticed this memory management mismatch while working on similar
>> debugfs string initialization fixes [1] recently.
>>
>> [1] https://lore.kernel.org/driver-core/20260317185920.43387-1-hanguidong02@gmail.com/
> 
> Hello Georgi,
> 
> Gentle ping on this patch.
> 
> Just wanted to note that my other related fix has already been accepted [1].
> 
> Could you please let me know if this fell through the cracks, or if
> you have any feedback or modification requests? I'd be very happy to
> address them.

Hello,

Thanks for the patch! I applied it already and it's available in today's linux-next.

Thanks,
Georgi

      reply	other threads:[~2026-04-02 16:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-18  2:48 [PATCH] interconnect: debugfs: fix devm_kstrdup and kfree mismatch Gui-Dong Han
2026-03-18  4:26 ` Kuan-Wei Chiu
2026-03-22  9:34 ` Markus Elfring
2026-04-02 15:42 ` Gui-Dong Han
2026-04-02 16:00   ` Georgi Djakov [this message]

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=01a921b7-4b8d-4df6-9840-300a8c143e71@kernel.org \
    --to=djakov@kernel.org \
    --cc=akaieurus@gmail.com \
    --cc=hanguidong02@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=me@ziyao.cc \
    --cc=visitorckw@gmail.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