From: sashiko-bot@kernel.org
To: "Yuho Choi" <dbgh9129@gmail.com>
Cc: vkoul@kernel.org, Frank.Li@kernel.org, dmaengine@vger.kernel.org
Subject: Re: [PATCH v1] dmaengine: qcom: hidma-mgmt: Fix sysfs cleanup on setup failure
Date: Mon, 08 Jun 2026 03:16:45 +0000 [thread overview]
Message-ID: <20260608031645.8E59F1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260608030846.2602111-1-dbgh9129@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Reliance on `kobject_put` without `kobject_del` for sysfs cleanup leads to use-after-free
--
commit a6dc90d05cf8a69c255834fbadc8ca4eb60dbe56
Author: Yuho Choi <dbgh9129@gmail.com>
dmaengine: qcom: hidma-mgmt: Fix sysfs cleanup on setup failure
hidma_mgmt_init_sys() creates the chanops kobject, per-channel
kobjects and sysfs files incrementally. If a later creation step fails,
the function returns without tearing down the objects already created.
> diff --git a/drivers/dma/qcom/hidma_mgmt_sys.c b/drivers/dma/qcom/hidma_mgmt_sys.c
> --- a/drivers/dma/qcom/hidma_mgmt_sys.c
> +++ b/drivers/dma/qcom/hidma_mgmt_sys.c
[ ... ]
> @@ -231,20 +231,52 @@ static int create_sysfs_entry_channel(struct hidma_mgmt_dev *mdev, char *name,
> return sysfs_create_file(parent, &chattr->attr.attr);
> }
>
> +static void hidma_mgmt_uninit_sys(struct hidma_mgmt_dev *mdev,
> + unsigned int sysfs_count,
> + unsigned int chroot_count)
> +{
> + unsigned int i;
> +
> + for (i = 0; i < sysfs_count; i++) {
> + struct attribute attr = { .name = hidma_mgmt_files[i].name };
> +
> + sysfs_remove_file(&mdev->pdev->dev.kobj, &attr);
> + }
> +
> + for (i = 0; i < chroot_count; i++) {
> + kobject_put(mdev->chroots[i]);
[Severity: High]
This is a pre-existing issue, but does this teardown logic still leave a
potential use-after-free?
Since the sysfs attributes (chattr) and their names are allocated using
devm_kmalloc() and devm_kstrdup() in create_sysfs_entry_channel(), devres
will free them immediately upon probe failure or device unbind.
If userspace holds an open file descriptor to any of the per-channel sysfs
files, or if CONFIG_DEBUG_KOBJECT_RELEASE is enabled, kobject_put() will
only decrement the reference count and the implicit kobject_del() inside
kobject_release() will be delayed. A subsequent read or write to the open
sysfs file would then dereference the already freed chattr memory.
Should kobject_del() be explicitly called before kobject_put() here to
synchronously remove the sysfs directory and files before devres frees the
backing memory?
> + mdev->chroots[i] = NULL;
> + }
> +
> + if (mdev->chanops) {
> + kobject_put(mdev->chanops);
> + mdev->chanops = NULL;
> + }
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260608030846.2602111-1-dbgh9129@gmail.com?part=1
prev parent reply other threads:[~2026-06-08 3:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-08 3:08 [PATCH v1] dmaengine: qcom: hidma-mgmt: Fix sysfs cleanup on setup failure Yuho Choi
2026-06-08 3:16 ` sashiko-bot [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=20260608031645.8E59F1F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=dbgh9129@gmail.com \
--cc=dmaengine@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vkoul@kernel.org \
/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