From: Mike Leach <mike.leach@arm.com>
To: Yingchao Deng <dengyingchao@kylinsec.com.cn>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
James Clark <james.clark@linaro.org>, Leo Yan <leo.yan@arm.com>
Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, qinyungao@kylinsec.com.cn,
luoqiu@kylinsec.com.cn, liudalin@kylinsec.com.cn, nd@arm.com
Subject: Re: [PATCH] coresight: syscfg: Fix null pointer dereference when configfs init fails
Date: Tue, 29 Sep 2026 13:20:59 +0100 [thread overview]
Message-ID: <59e10194-cc34-4535-a8c9-6cfb808582c2@arm.com> (raw)
In-Reply-To: <C73E0F9BDC0A8FE7+20260928123515.2032-1-dengyingchao@kylinsec.com.cn>
Reviewed-by: Mike Leach <mike.leach@arm.com>
On 9/28/26 13:35, Yingchao Deng wrote:
> If cscfg_configfs_init() fails, cscfg_init() takes the exit_err path:
>
> cscfg_init() -> cscfg_clear_device() -> cscfg_configfs_release()
> -> configfs_unregister_subsystem()
>
> which tears down a configfs subsystem that was never registered.
> configfs_unregister_subsystem() begins with:
>
> struct dentry *dentry = dget(group->cg_item.ci_dentry);
> struct dentry *root = dentry->d_sb->s_root;
>
> ci_dentry is assigned in configfs_create_dir() only once the subsystem
> directory has been created, which never happened here. cscfg_mgr
> comes from kzalloc_obj(), so ci_dentry is still NULL, and dget()
> hands a NULL dentry back unchanged - the next line dereferences it.
>
> Handle the failure in cscfg_init() directly: unregister the device and
> return the error, releasing the devres-allocated config item type and
> cscfg_mgr without touching the subsystem.
>
> Fixes: a13d5a246aca ("coresight: syscfg: Add initial configfs support")
> Suggested-by: Leo Yan <leo.yan@arm.com>
> Link: https://lore.kernel.org/all/20260924162404.GN200420@e132581.arm.com/
> Signed-off-by: Yingchao Deng <dengyingchao@kylinsec.com.cn>
> ---
> drivers/hwtracing/coresight/coresight-syscfg.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-syscfg.c b/drivers/hwtracing/coresight/coresight-syscfg.c
> index 2bfdd7b45e49..00b29d1656c0 100644
> --- a/drivers/hwtracing/coresight/coresight-syscfg.c
> +++ b/drivers/hwtracing/coresight/coresight-syscfg.c
> @@ -1299,8 +1299,10 @@ int __init cscfg_init(void)
>
> /* initialise configfs subsystem */
> err = cscfg_configfs_init(cscfg_mgr);
> - if (err)
> - goto exit_err;
> + if (err) {
> + device_unregister(cscfg_device());
> + return err;
> + }
>
> /* preload built-in configurations */
> err = cscfg_preload(THIS_MODULE);
prev parent reply other threads:[~2026-09-29 12:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-28 12:35 [PATCH] coresight: syscfg: Fix null pointer dereference when configfs init fails Yingchao Deng
2026-09-29 12:20 ` Mike Leach [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=59e10194-cc34-4535-a8c9-6cfb808582c2@arm.com \
--to=mike.leach@arm.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=coresight@lists.linaro.org \
--cc=dengyingchao@kylinsec.com.cn \
--cc=james.clark@linaro.org \
--cc=leo.yan@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liudalin@kylinsec.com.cn \
--cc=luoqiu@kylinsec.com.cn \
--cc=nd@arm.com \
--cc=qinyungao@kylinsec.com.cn \
--cc=suzuki.poulose@arm.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;
as well as URLs for NNTP newsgroup(s).