From: Vikash Garodia <vikash.garodia@oss.qualcomm.com>
To: sashiko-reviews@lists.linux.dev
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [RFC PATCH 06/11] media: iris: Add hooks for pixel and non-pixel context banks
Date: Tue, 14 Jul 2026 19:13:46 +0530 [thread overview]
Message-ID: <3def9abb-ee40-42e4-876b-b865cee82e67@oss.qualcomm.com> (raw)
In-Reply-To: <20260709135418.9421B1F000E9@smtp.kernel.org>
On 7/9/2026 7:24 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
>
> New issues:
> - [High] Unregistering context bank devices in `remove` while V4L2 FDs are open causes DMA API mismatch and IOMMU faults.
> - [Medium] Hardcoded platform device ID causes name collision if multiple Iris instances exist.
>
> Pre-existing issues:
> - [High] Missing cancellation of sys_error_handler delayed work leads to Use-After-Free.
> - [High] Use-After-Free on `iris_core` during deferred V4L2 close due to `devm_kzalloc`.
> --
>
> --- Patch [6]: [RFC PATCH 06/11] media: iris: Add hooks for pixel and non-pixel context banks ---
> commit ac38538cd2eb8a1aa776f7262b1bd953d7ac3a78
> Author: Vikash Garodia <vikash.garodia@oss.qualcomm.com>
>
> media: iris: Add hooks for pixel and non-pixel context banks
>
> Iris platforms use separate context-bank devices for the pixel and
> non-pixel domains. Add platform hooks to create and destroy those
> subdevices, and wire them up for the affected platforms.
>
>> diff --git a/drivers/media/platform/qcom/iris/iris_platform_sm8550.c b/drivers/media/platform/qcom/iris/iris_platform_sm8550.c
>> new file mode 100644
>> index 0000000000000..bea904a9249ba
>> --- /dev/null
>> +++ b/drivers/media/platform/qcom/iris/iris_platform_sm8550.c
>> @@ -0,0 +1,71 @@
>
> [ ... ]
>
>> +static int sm8550_init_cb_devs(struct iris_core *core)
>> +{
>> + struct device *dev;
>> +
>> + dev = iris_create_cb_dev(core, "non-pixel");
>
> [Severity: Medium]
> When creating the child context banks here, could this cause a name
> collision if there are multiple Iris instances?
>
> Looking at iris_create_cb_dev() in iris_resources.c, it zero-initializes
> struct platform_device_info, which forces the device id to 0:
>
> drivers/media/platform/qcom/iris/iris_resources.c:iris_create_cb_dev() {
> struct platform_device_info plat_dev_info = {};
> ...
> }
>
> This causes platform_device_register_full() to assign exact names like
> "pixel.0" and "non-pixel.0". If a second Iris instance probes, wouldn't
> kobject_add() return -EEXIST? Should PLATFORM_DEVID_AUTO be used instead?
>
>> + if (IS_ERR(dev))
>> + return PTR_ERR(dev);
>> +
>> + core->np_dev = dev;
>> +
>> + dev = iris_create_cb_dev(core, "pixel");
>
> [ ... ]
>
>> +static void sm8550_deinit_cb_devs(struct iris_core *core)
>> +{
>> + if (core->p_dev)
>> + platform_device_unregister(to_platform_device(core->p_dev));
>> + if (core->np_dev)
>> + platform_device_unregister(to_platform_device(core->np_dev));
>> +
>> + core->p_dev = NULL;
>> + core->np_dev = NULL;
>> +}
>
> [Severity: High]
> Does unregistering the context bank devices here cause a DMA API mismatch if
> a user-space application still holds a V4L2 file descriptor open?
>
> V4L2 file handles can outlive the driver's remove callback. If a user closes
> the device after remove completes, iris_close() calls
> iris_destroy_all_internal_buffers() which calls iris_get_cb_dev().
>
> Since p_dev and np_dev are NULL, iris_get_cb_dev() falls back to core->dev:
>
> drivers/media/platform/qcom/iris/iris_resources.c:iris_get_cb_dev() {
> ...
> return dev ? dev : core->dev;
> }
>
> This means dma_free_attrs() is executed using core->dev, but the memory
> was originally allocated with the context bank devices. Could this mismatch
> violate the DMA API and cause IOMMU unmap faults?
>
> [Severity: High]
> This is a pre-existing issue, but does tying the iris_core struct to the
> device lifecycle result in a Use-After-Free during a deferred V4L2 close?
>
> In iris_probe(), core is allocated with devm_kzalloc():
>
> drivers/media/platform/qcom/iris/iris_probe.c:iris_probe() {
> ...
> core = devm_kzalloc(&pdev->dev, sizeof(*core), GFP_KERNEL);
> ...
> }
>
> When the driver is unbound, iris_remove() returns and devres frees core.
> If an application holds a file descriptor open, iris_close() is eventually
> called, which dereferences inst->core to clean up sessions:
>
> drivers/media/platform/qcom/iris/iris_vidc.c:iris_close() {
> ...
> iris_remove_session(inst);
> ...
> }
>
> Since core is already freed, won't this cause memory corruption?
>
> [Severity: High]
> This isn't a bug introduced by this patch, but is it possible for the
> sys_error_handler delayed work to trigger a Use-After-Free if it runs
> during or after driver unbind?
Yes, this is addressed with
https://lore.kernel.org/all/20260604054708.42426-1-dennylin0707@gmail.com/
>
> The sys_error_handler is dynamically scheduled on hardware errors, but
> iris_remove() does not appear to cancel it:
>
> drivers/media/platform/qcom/iris/iris_probe.c:iris_remove() {
> struct iris_core *core;
>
> core = platform_get_drvdata(pdev);
> if (!core)
> return;
>
> iris_core_deinit(core);
> }
>
> If the unbind occurs while the work is pending or running, core will be
> freed by devres after iris_remove() returns. When the workqueue executes
> iris_sys_error_handler(), won't it dereference the freed core?
>
next prev parent reply other threads:[~2026-07-14 13:43 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <7GAZnP6jPoRrcDnaVzeaB98cONLhtvbiEXV1yD5MJJrA9pCnC9lmlSiCGA8vlDezSXADjmFiqo3ZdClO5SxCFA==@protonmail.internalid>
2026-07-09 12:35 ` [RFC PATCH 00/11] : media: iris: Migrate iommus to iris sub nodes Vikash Garodia
2026-07-09 12:35 ` [RFC PATCH 01/11] dt-bindings: media: qcom,sm8550-iris: Add vpu " Vikash Garodia
2026-07-09 12:46 ` sashiko-bot
2026-07-09 12:50 ` Dmitry Baryshkov
2026-07-10 6:02 ` Vikash Garodia
2026-07-10 15:53 ` Dmitry Baryshkov
2026-07-11 5:46 ` Vikash Garodia
2026-07-10 22:02 ` Bryan O'Donoghue
2026-07-24 11:15 ` Dmitry Baryshkov
2026-07-24 11:38 ` Vikash Garodia
2026-07-09 12:35 ` [RFC PATCH 02/11] media: iris: Add hooks to initialize and tear down context banks Vikash Garodia
2026-07-09 12:57 ` sashiko-bot
2026-07-09 12:35 ` [RFC PATCH 03/11] media: iris: Add helper to create a context bank device Vikash Garodia
2026-07-09 13:10 ` sashiko-bot
2026-07-14 13:49 ` Vikash Garodia
2026-07-09 12:35 ` [RFC PATCH 04/11] media: iris: Add helper to select relevant " Vikash Garodia
2026-07-09 12:35 ` [RFC PATCH 05/11] media: iris: Skip DMA mask setting to core device when IOMMU is not mapped Vikash Garodia
2026-07-09 13:10 ` Dmitry Baryshkov
2026-07-09 13:43 ` sashiko-bot
2026-07-14 13:48 ` Vikash Garodia
2026-07-09 12:35 ` [RFC PATCH 06/11] media: iris: Add hooks for pixel and non-pixel context banks Vikash Garodia
2026-07-09 13:14 ` Dmitry Baryshkov
2026-07-10 6:32 ` Vikash Garodia
2026-07-10 16:03 ` Dmitry Baryshkov
2026-07-09 13:54 ` sashiko-bot
2026-07-10 16:12 ` Dmitry Baryshkov
2026-07-14 7:23 ` Vikash Garodia
2026-07-14 13:39 ` Vikash Garodia
2026-07-14 13:43 ` Vikash Garodia [this message]
2026-07-09 12:35 ` [RFC PATCH 07/11] arm64: dts: qcom: hamoa: Move Iris IOMMUs to sub nodes Vikash Garodia
2026-07-09 13:03 ` Dmitry Baryshkov
2026-07-10 6:05 ` Vikash Garodia
2026-07-10 21:05 ` Dmitry Baryshkov
2026-07-09 14:10 ` sashiko-bot
2026-07-14 13:02 ` Vikash Garodia
2026-07-10 10:48 ` Bryan O'Donoghue
2026-07-10 22:46 ` Bryan O'Donoghue
2026-07-12 12:19 ` Dmitry Baryshkov
2026-07-13 6:02 ` Vikash Garodia
2026-07-16 9:07 ` Vikash Garodia
2026-07-29 10:10 ` Krzysztof Kozlowski
2026-07-09 12:35 ` [RFC PATCH 08/11] arm64: dts: qcom: sm8550: Move Iris IOMMUs to child nodes Vikash Garodia
2026-07-09 14:30 ` sashiko-bot
2026-07-14 13:01 ` Vikash Garodia
2026-07-09 12:35 ` [RFC PATCH 09/11] arm64: dts: qcom: lemans: " Vikash Garodia
2026-07-09 14:44 ` sashiko-bot
2026-07-14 11:08 ` Vikash Garodia
2026-07-09 12:35 ` [RFC PATCH 10/11] arm64: dts: qcom: monaco: " Vikash Garodia
2026-07-09 15:03 ` sashiko-bot
2026-07-14 11:07 ` Vikash Garodia
2026-07-09 12:35 ` [RFC PATCH 11/11] arm64: dts: qcom: sm8650: " Vikash Garodia
2026-07-09 15:29 ` sashiko-bot
2026-07-14 11:06 ` Vikash Garodia
2026-07-10 10:35 ` [RFC PATCH 00/11] : media: iris: Migrate iommus to iris sub nodes Bryan O'Donoghue
2026-07-10 13:36 ` Vikash Garodia
2026-07-10 13:38 ` Bryan O'Donoghue
2026-07-10 14:02 ` Vikash Garodia
2026-07-12 12:24 ` Dmitry Baryshkov
2026-07-13 5:59 ` Vikash Garodia
2026-07-12 11:51 ` Daniel J Blueman
2026-07-13 5:53 ` Vikash Garodia
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=3def9abb-ee40-42e4-876b-b865cee82e67@oss.qualcomm.com \
--to=vikash.garodia@oss.qualcomm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@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