public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: Gui-Dong Han <hanguidong02@gmail.com>,
	linux-pm@vger.kernel.org, Georgi Djakov <djakov@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org,
	Kuan-Wei Chiu <visitorckw@gmail.com>,
	Wang Jiayue <akaieurus@gmail.com>, Yao Zi <me@ziyao.cc>
Subject: Re: [PATCH] interconnect: debugfs: fix devm_kstrdup and kfree mismatch
Date: Sun, 22 Mar 2026 10:34:06 +0100	[thread overview]
Message-ID: <68f0613c-321a-45cd-abf7-76e59159d9c5@web.de> (raw)
In-Reply-To: <20260318024815.7655-1-hanguidong02@gmail.com>

> debugfs_write_file_str() uses standard kfree() to release old strings.

Why would such information matter here?


> 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.

Would an other description approach be clearer for involved dependencies?


> Fix this by using standard kstrdup() instead.

Interesting …

https://elixir.bootlin.com/linux/v7.0-rc4/source/drivers/interconnect/debugfs-client.c#L139-L169


>                                               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.

Should string lifetimes be reconsidered for the mentioned function implementation?


>                                                            The error
> handling path is also simplified by taking advantage of the fact that
> kfree(NULL) is a safe no-op.

I tend to interpret source code simplifications in other directions.


See also once more:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/stable-kernel-rules.rst?h=v7.0-rc4#n34

Regards,
Markus

  parent reply	other threads:[~2026-03-22  9:34 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 [this message]
2026-04-02 15:42 ` Gui-Dong Han
2026-04-02 16:00   ` Georgi Djakov

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=68f0613c-321a-45cd-abf7-76e59159d9c5@web.de \
    --to=markus.elfring@web.de \
    --cc=akaieurus@gmail.com \
    --cc=djakov@kernel.org \
    --cc=hanguidong02@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --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