From: sashiko-bot@kernel.org
To: "Dawei Feng" <dawei.feng@seu.edu.cn>
Cc: linux-media@vger.kernel.org
Subject: Re: [PATCH] media: atomisp: Fix resource leak in atomisp_pci_probe()
Date: Mon, 08 Jun 2026 08:57:09 +0000 [thread overview]
Message-ID: <20260608085710.04EB81F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260608082706.3287831-1-dawei.feng@seu.edu.cn>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The v4l2 async notifier is never unregistered or cleaned up, leading to a memory leak of async subdevice connection objects and dangling notifiers resulting in a Use-After-Free.
--
commit b7444e6b542badbafff9a7d15d5037c35782ba7c
Author: Dawei Feng <dawei.feng@seu.edu.cn>
media: atomisp: Fix resource leak in atomisp_pci_probe()
This commit fixes a resource leak by unregistering subdev entities if
atomisp_register_entities() fails during atomisp_pci_probe().
> diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
> index 900a67552d6a0..d4e4e845f66e6 100644
> --- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
> +++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
> @@ -1401,6 +1401,7 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
> err = atomisp_register_entities(isp);
> if (err < 0) {
> dev_err(&pdev->dev, "atomisp_register_entities failed (%d)\n", err);
> + atomisp_subdev_unregister_entities(&isp->asd);
> goto error_uninitialize_modules;
> }
[Severity: High]
This is a pre-existing issue, but while looking at the error paths being
fixed here, is there also a memory leak and use-after-free risk related to
the async notifier?
In atomisp_pci_probe(), the notifier is registered via
v4l2_async_nf_register(), adding it to the global notifier_list. However,
the error paths and the driver teardown function atomisp_pci_remove()
appear to entirely omit v4l2_async_nf_unregister() and
v4l2_async_nf_cleanup():
drivers/staging/media/atomisp/pci/atomisp_v4l2.c:atomisp_pci_probe() {
...
err = v4l2_async_nf_register(&isp->notifier);
if (err) {
dev_err(isp->dev, "failed to register async notifier : %d\n", err);
goto error_unload_firmware;
}
return 0;
error_unload_firmware:
atomisp_pm_uninit(isp);
ia_css_unload_firmware();
...
}
Does this code permanently leak the memory allocated for async subdevices via
v4l2_async_nf_add_fwnode_remote() because cleanup is never called?
Additionally, since the isp struct is allocated via devm_kzalloc(), could
omitting the unregister call leave a dangling pointer in the global
notifier_list when the driver is unloaded or when the probe fails, potentially
causing a use-after-free on subsequent list iterations?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260608082706.3287831-1-dawei.feng@seu.edu.cn?part=1
prev parent reply other threads:[~2026-06-08 8:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-08 8:27 [PATCH] media: atomisp: Fix resource leak in atomisp_pci_probe() Dawei Feng
2026-06-08 8:51 ` Dan Carpenter
2026-06-08 14:05 ` Dawei Feng
2026-06-08 8:57 ` 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=20260608085710.04EB81F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dawei.feng@seu.edu.cn \
--cc=linux-media@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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