From: sashiko-bot@kernel.org
To: "Pei Xiao" <xiaopei01@kylinos.cn>
Cc: cassel@kernel.org, linux-ide@vger.kernel.org, dlemoal@kernel.org
Subject: Re: [PATCH] test: ata
Date: Wed, 29 Jul 2026 11:26:08 +0000 [thread overview]
Message-ID: <20260729112609.3CD3A1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <170fe5b11ca8bffc32b4ec6588c289b29da11896.1785323372.git.xiaopei01@kylinos.cn>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Medium] The commit message is completely devoid of technical details, failing to describe the changes, their purpose, or the problem being solved.
Pre-existing issues:
- [High] pata_parport_unregister_driver() does not unregister the devices associated with the unloaded protocol, leaving dangling devices on the bus that hold freed pointers.
--
--- Patch [1]: [PATCH] test: ata ---
commit 787e1d65e64282ddc25d6c43593b6cd3674b9345
Author: Pei Xiao <xiaopei01@kylinos.cn>
test: ata
This commit modifies locking in pata_parport by adopting guard(mutex) for
pi_mutex in new_device_store() and extending the mutex_unlock call in
pata_parport_unregister_driver() to also cover driver_unregister().
> test: ata
>
> hi maintainer and shuangpeng,
>
> I tested this patch passed.
[Severity: Medium]
Could this commit message be expanded with more technical details?
The message only mentions that the patch was tested, but it does not describe
the functional changes being introduced, such as expanding the lock scope to
protect driver_find() and changing the lock ordering in the unregister path.
Describing the problem and the rationale for the changes would greatly assist
with review and future maintenance.
> diff --git a/drivers/ata/pata_parport/pata_parport.c b/drivers/ata/pata_parport/pata_parport.c
> index 40baeac594a9f..34f09192a4190 100644
> --- a/drivers/ata/pata_parport/pata_parport.c
> +++ b/drivers/ata/pata_parport/pata_parport.c
[ ... ]
> @@ -618,8 +619,9 @@ void pata_parport_unregister_driver(struct pi_protocol *pr)
> break;
> }
> idr_remove(&protocols, id);
> - mutex_unlock(&pi_mutex);
> driver_unregister(&pr->driver);
> + mutex_unlock(&pi_mutex);
> +
> }
[Severity: High]
This is a pre-existing issue, but does pata_parport_unregister_driver() leak
devices?
When a protocol module's init function registers multiple protocols (like
kbic_init registering k951 and k971) and a subsequent registration fails, it
will call pata_parport_unregister_driver() on the already-registered protocol.
While the protocol is removed from the IDR and the driver is unregistered, the
dynamically created pi_adapter devices are not cleaned up. Since the module
init returns an error, the module loader frees the module memory, bypassing
the reference held by the devices.
If these dangling devices are later removed (for example, via sysfs
delete_device), pi_remove_one() calls pi_disconnect(pi), which dereferences
the freed pi->proto->disconnect pointer, leading to a kernel crash.
Should the associated devices be unregistered here as well?
--
Sashiko AI review · https://sashiko.dev/#/patchset/170fe5b11ca8bffc32b4ec6588c289b29da11896.1785323372.git.xiaopei01@kylinos.cn?part=1
prev parent reply other threads:[~2026-07-29 11:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 2:40 [BUG] ata: pata_parport: KASAN slab-use-after-free in driver_find Shuangpeng Bai
2026-07-28 3:01 ` Damien Le Moal
2026-07-28 4:34 ` Shuangpeng
2026-07-29 11:13 ` [PATCH] test: ata Pei Xiao
2026-07-29 11:26 ` 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=20260729112609.3CD3A1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=xiaopei01@kylinos.cn \
/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