From: Vishnu Reddy <busanna.reddy@oss.qualcomm.com>
To: sashiko-reviews@lists.linux.dev
Cc: robh@kernel.org, conor+dt@kernel.org, media-ci@linuxtv.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH v10 11/14] media: iris: Add hooks for pixel and non-pixel context banks
Date: Mon, 27 Jul 2026 10:16:30 +0530 [thread overview]
Message-ID: <c37f55fc-731d-30da-b7d0-141e7ddefbba@oss.qualcomm.com> (raw)
In-Reply-To: <20260726060345.01C021F000E9@smtp.kernel.org>
On 7/26/2026 11:33 AM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
>
> New issues:
> - [High] Dangling pointer in `vb2_queue->dev` due to synchronous unregistration of context-bank platform devices.
>
> Pre-existing issues:
> - [High] Missing cancel_delayed_work_sync() for sys_error_handler in iris_remove() leads to use-after-free.
> --
>
> --- Patch [11]: [PATCH v10 11/14] media: iris: Add hooks for pixel and non-pixel context banks ---
> commit 1f1fdc377aea1a90f259a986e4bc14be351b3bc0
> 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, non-pixel
> firmware domains. Add platform hooks to create and destroy those
> subdevices, providing a interface for their lifecycle management across
> platforms.
>
>> diff --git a/drivers/media/platform/qcom/iris/iris_vpu3x.c b/drivers/media/platform/qcom/iris/iris_vpu3x.c
>> index ec35ad4f86102..bc95be22ed96d 100644
>> --- a/drivers/media/platform/qcom/iris/iris_vpu3x.c
>> +++ b/drivers/media/platform/qcom/iris/iris_vpu3x.c
>> @@ -397,6 +397,52 @@ static u64 iris_vpu36_get_required_freq(struct iris_inst *inst)
>> return max(vcodec0_freq, vcodec1_freq);
>> }
>>
>> +static int iris_vpu3x_init_cb_devs(struct iris_core *core)
>> +{
>> + struct device *dev;
>> +
>> + dev = iris_create_cb_dev(core, "non-pixel");
>> + if (IS_ERR(dev))
>> + return PTR_ERR(dev);
>> +
>> + core->np_dev = dev;
>> +
>> + dev = iris_create_cb_dev(core, "pixel");
>> + if (IS_ERR(dev))
>> + goto unreg_np_dev;
>> +
>> + core->p_dev = dev;
>> +
>> + dev = iris_create_cb_dev(core, "video-firmware");
>> + if (IS_ERR(dev))
>> + goto unreg_p_dev;
>> +
>> + core->fw_dev = dev;
>> +
>> + return 0;
>> +
>> +unreg_p_dev:
>> + if (core->p_dev)
>> + platform_device_unregister(to_platform_device(core->p_dev));
>> + core->p_dev = NULL;
>> +unreg_np_dev:
>> + if (core->np_dev)
>> + platform_device_unregister(to_platform_device(core->np_dev));
>> + core->np_dev = NULL;
>> +
>> + return PTR_ERR(dev);
>> +}
>> +
>> +static void iris_vpu3x_deinit_cb_devs(struct iris_core *core)
>> +{
>> + if (core->fw_dev)
>> + platform_device_unregister(to_platform_device(core->fw_dev));
>> + 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));
>> +}
> [Severity: High]
> Does this code synchronously free the context-bank platform devices without
> waiting for userspace V4L2 file descriptors to close?
>
> If a userspace application holds a video device file descriptor open during
> driver unbind, this function will unregister and free the context-bank
> platform devices.
Remove callback cannot execute if driver module->refcnt, ref-counted
during open, and not decremented with corresponding close call.
> However, in iris_m2m_queue_init(), the context-bank devices are assigned to
> vb2_queue->dev:
>
> drivers/media/platform/qcom/iris/iris_vidc.c:iris_m2m_queue_init() {
> ...
> src_vq->dev = iris_get_cb_dev(inst, BUF_INPUT);
> ...
> dst_vq->dev = iris_get_cb_dev(inst, BUF_OUTPUT);
> ...
> }
>
> Because the V4L2 core does not hold a reference to q->dev during videobuf2
> queue initialization, won't this result in a use-after-free when userspace
> finally closes the file descriptor and v4l2_m2m_ctx_release() triggers
> vb2_queue_release() to unmap DMA buffers?
>
> [Severity: High]
> This is a pre-existing issue, but does iris_remove() fail to cancel the
> sys_error_handler delayed work before returning?
This is addressed here
https://lore.kernel.org/all/20260604054708.42426-1-dennylin0707@gmail.com
> drivers/media/platform/qcom/iris/iris_probe.c:iris_remove() {
> ...
> iris_core_deinit(core);
>
> video_unregister_device(core->vdev_dec);
> video_unregister_device(core->vdev_enc);
>
> v4l2_device_unregister(&core->v4l2_dev);
>
> iris_deinit_cb_devs(core);
>
> mutex_destroy(&core->lock);
> }
>
> If a system fatal error triggers an interrupt just before or during module
> removal, the sys_error_handler delayed work could be scheduled.
>
> Since iris_remove() doesn't explicitly cancel this work before returning,
> could the handler execute after the devm_kzalloc-managed core structure is
> freed?
>
> drivers/media/platform/qcom/iris/iris_probe.c:iris_sys_error_handler() {
> struct iris_core *core =
> container_of(work, struct iris_core, sys_error_handler.work);
>
> iris_core_deinit(core);
> iris_core_init(core);
> }
>
next prev parent reply other threads:[~2026-07-27 4:46 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-26 5:49 [PATCH v10 00/14] media: iris: Add support for glymur platform Vishnu Reddy
2026-07-26 5:49 ` [PATCH v10 01/14] dt-bindings: media: qcom,glymur-iris: Add glymur video codec Vishnu Reddy
2026-07-26 6:00 ` sashiko-bot
2026-07-27 4:44 ` Vishnu Reddy
2026-07-26 5:49 ` [PATCH v10 02/14] media: iris: Add hooks to initialize and tear down context banks Vishnu Reddy
2026-07-26 6:01 ` sashiko-bot
2026-07-26 5:49 ` [PATCH v10 03/14] media: iris: Add helper to create a context bank device Vishnu Reddy
2026-07-26 6:03 ` sashiko-bot
2026-07-27 4:44 ` Vishnu Reddy
2026-07-26 5:49 ` [PATCH v10 04/14] media: iris: Add helper to select relevant " Vishnu Reddy
2026-07-26 6:11 ` sashiko-bot
2026-07-26 5:49 ` [PATCH v10 05/14] media: iris: Skip DMA mask setting to core device when IOMMU is not mapped Vishnu Reddy
2026-07-26 6:05 ` sashiko-bot
2026-07-27 4:45 ` Vishnu Reddy
2026-07-26 5:49 ` [PATCH v10 06/14] media: iris: Enable Secure PAS support with IOMMU managed by Linux Vishnu Reddy
2026-07-26 6:08 ` sashiko-bot
2026-07-27 4:45 ` Vishnu Reddy
2026-07-26 5:49 ` [PATCH v10 07/14] media: iris: Replace enum-indexed clock and power domain tables with per-block structures Vishnu Reddy
2026-07-26 6:06 ` sashiko-bot
2026-07-26 5:49 ` [PATCH v10 08/14] media: iris: Add power sequence for glymur Vishnu Reddy
2026-07-26 6:05 ` sashiko-bot
2026-07-27 4:45 ` Vishnu Reddy
2026-07-26 5:49 ` [PATCH v10 09/14] media: iris: Handle CPU_CS_SCIACMDARG3 register write via program bootup registers hook Vishnu Reddy
2026-07-26 6:03 ` sashiko-bot
2026-07-27 4:46 ` Vishnu Reddy
2026-07-26 5:49 ` [PATCH v10 10/14] media: iris: Add support to select core for dual core platforms Vishnu Reddy
2026-07-26 6:18 ` sashiko-bot
2026-07-26 5:49 ` [PATCH v10 11/14] media: iris: Add hooks for pixel and non-pixel context banks Vishnu Reddy
2026-07-26 6:03 ` sashiko-bot
2026-07-27 4:46 ` Vishnu Reddy [this message]
2026-07-26 5:49 ` [PATCH v10 12/14] media: iris: Add platform data for glymur Vishnu Reddy
2026-07-26 5:49 ` [PATCH v10 13/14] arm64: dts: qcom: glymur: Add iris video node Vishnu Reddy
2026-07-26 5:49 ` [PATCH v10 14/14] arm64: dts: qcom: glymur-crd: Enable iris video codec node Vishnu Reddy
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=c37f55fc-731d-30da-b7d0-141e7ddefbba@oss.qualcomm.com \
--to=busanna.reddy@oss.qualcomm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=media-ci@linuxtv.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