All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Dmitry Baryshkov" <dmitry.baryshkov@oss.qualcomm.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org,
	media-ci@linuxtv.org
Subject: Re: [PATCH v8 01/18] media: iris: Add Gen2 firmware autodetect and fallback
Date: Thu, 30 Jul 2026 15:37:25 +0000	[thread overview]
Message-ID: <20260730153725.A2E781F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260730-iris-ar50lt-v8-1-6597c08cea6f@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:

New issues:
- [High] Uninitialized memory scan in firmware generation detection.

Pre-existing issues:
- [High] Kernel crash: IRQ is enabled before the HFI ops are initialized, leading to a NULL pointer dereference on early interrupts.
- [High] Use-After-Free of `iris_core` due to uncancelled delayed work during module teardown.
- [High] Race condition in `iris_open` allows concurrent callers to bypass the hardware initialization wait.
--

--- Patch [1]: [PATCH v8 01/18] media: iris: Add Gen2 firmware autodetect and fallback ---
commit a2c8d521a685de60d5919ebd8f396f7a268a25cc
Author: Dikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>

media: iris: Add Gen2 firmware autodetect and fallback

Some Iris platforms support both Gen1 and Gen2 HFI firmware images.
Update the firmware loading logic to handle this generically by
preferring Gen2 when available, while safely falling back to Gen1
when required.

[ ... ]

> diff --git a/drivers/media/platform/qcom/iris/iris_core.c b/drivers/media/platform/qcom/iris/iris_core.c
> index 52bf56e517f91..6dbe18be5b495 100644
> --- a/drivers/media/platform/qcom/iris/iris_core.c
> +++ b/drivers/media/platform/qcom/iris/iris_core.c
> @@ -79,6 +80,7 @@ int iris_core_init(struct iris_core *core)
>  		goto error_unload_fw;
>  
>  	core->iris_firmware_data->init_hfi_ops(core);

[Severity: High]
This isn't a bug introduced by this patch, but could this initialization
sequence cause a NULL pointer dereference on early interrupts?

In iris_core_init(), iris_vpu_power_on() is called earlier, which unmasks the
interrupt via enable_irq(core->irq). At that point, core->hfi_sys_ops is still
NULL because init_hfi_ops() hasn't run yet.

If an interrupt fires early (for example, from the VPU firmware booting),
iris_hfi_isr_handler() will execute and unconditionally dereference
core->hfi_sys_ops->sys_hfi_response_handler. Should init_hfi_ops() be called
before enabling the IRQ?

[Severity: High]
This is a pre-existing issue, but does this function have a race condition that
allows concurrent callers to bypass the hardware initialization wait?

When a user opens the device, iris_core_init() acquires the lock, sets
core->state = IRIS_CORE_INIT, drops the lock, and then proceeds with the
lengthy initialization and iris_wait_for_system_response().

If a concurrent thread calls iris_open() and acquires the lock, it will see
core->state == IRIS_CORE_INIT, immediately return 0, and proceed to interact
with the hardware before the firmware has actually finished booting. Could this
lead to undefined behavior?

> +	iris_session_init_caps(core);
>  
>  	ret = iris_hfi_core_init(core);
>  	if (ret)

[ ... ]

> diff --git a/drivers/media/platform/qcom/iris/iris_firmware.c b/drivers/media/platform/qcom/iris/iris_firmware.c
> index 1a476146d7580..c5d2b9fd0502e 100644
> --- a/drivers/media/platform/qcom/iris/iris_firmware.c
> +++ b/drivers/media/platform/qcom/iris/iris_firmware.c

[ ... ]

> @@ -56,6 +209,9 @@ static int iris_load_fw_to_memory(struct iris_core *core, const char *fw_name)
>  	ret = qcom_mdt_load(dev, firmware, fw_name,
>  			    IRIS_PAS_ID, mem_virt, mem_phys, res_size, NULL);
>  
> +	if (!ret)
> +		iris_detect_firmware(core, fw_name, mem_virt, res_size, desc);

[Severity: High]
Could this scan uninitialized memory?

The memory region is mapped via memremap() using MEMREMAP_WC without being
zeroed, meaning it could retain contents from a previous boot or firmware load.
qcom_mdt_load() populates the memory but might leave gaps or leave the tail
end untouched.

Since iris_detect_firmware() is called with the total reserved memory size
(res_size) rather than the actual loaded firmware size, could the loop in
iris_detect_gen2_from_fwdata() scan past the valid loaded data and falsely
detect a leftover QC_IMAGE_VERSION_STRING from an older firmware?

> +
>  	memunmap(mem_virt);
>  err_release_fw:
>  	release_firmware(firmware);

[ ... ]

> diff --git a/drivers/media/platform/qcom/iris/iris_probe.c b/drivers/media/platform/qcom/iris/iris_probe.c
> index c2dcb50a27824..7fe31136df21b 100644
> --- a/drivers/media/platform/qcom/iris/iris_probe.c
> +++ b/drivers/media/platform/qcom/iris/iris_probe.c
> @@ -251,8 +251,6 @@ static int iris_probe(struct platform_device *pdev)
>  		return core->irq;

[Severity: High]
This is a pre-existing issue, but does the module teardown path leak a running
delayed work, leading to a use-after-free?

iris_probe() initializes a delayed work sys_error_handler which uses the core
pointer. In the teardown path, iris_remove() unregisters devices but does not
seem to call cancel_delayed_work_sync(&core->sys_error_handler).

Since the core struct is managed by devm_kzalloc, it is freed when
iris_remove() returns. If the delayed work was scheduled and runs after
removal, won't it dereference the freed core pointer?

>  	core->iris_platform_data = of_device_get_match_data(core->dev);
> -	core->iris_firmware_desc = core->iris_platform_data->firmware_desc;
> -	core->iris_firmware_data = core->iris_firmware_desc->firmware_data;
>  
>  	core->ubwc_cfg = qcom_ubwc_config_get_data();

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260730-iris-ar50lt-v8-0-6597c08cea6f@oss.qualcomm.com?part=1

  reply	other threads:[~2026-07-30 15:37 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <J0r-fdDYeS3FyqabzR_0wiwxC-2onZeePkUSfv0NavGV8KB3Anc-j8yKHqfY2I3X4VAiZpRkYSIZLaTwuyhKMA==@protonmail.internalid>
2026-07-30 15:20 ` [PATCH v8 00/18] media: iris: Add AR50LT core support and enable Agatti platform Dmitry Baryshkov
2026-07-30 15:20   ` [PATCH v8 01/18] media: iris: Add Gen2 firmware autodetect and fallback Dmitry Baryshkov
2026-07-30 15:37     ` sashiko-bot [this message]
2026-07-30 20:02     ` Bryan O'Donoghue
2026-07-30 15:20   ` [PATCH v8 02/18] media: iris: Skip UBWC configuration when not supported Dmitry Baryshkov
2026-07-30 15:32     ` sashiko-bot
2026-07-30 15:20   ` [PATCH v8 03/18] media: iris: drop IRIS_FMT_foo enumeration Dmitry Baryshkov
2026-07-30 15:20   ` [PATCH v8 04/18] media: iris: Filter UBWC raw formats based on hardware capabilities Dmitry Baryshkov
2026-07-30 15:20   ` [PATCH v8 05/18] media: iris: Introduce set_preset_register as a vpu_op Dmitry Baryshkov
2026-07-30 15:20   ` [PATCH v8 06/18] media: iris: Introduce interrupt_init " Dmitry Baryshkov
2026-07-30 15:20   ` [PATCH v8 07/18] media: iris: add vpu op hook to disable ARP buffer Dmitry Baryshkov
2026-07-30 15:41     ` sashiko-bot
2026-07-30 15:20   ` [PATCH v8 08/18] media: iris: Add platform data field for watchdog interrupt mask Dmitry Baryshkov
2026-07-30 15:32     ` sashiko-bot
2026-07-30 15:20   ` [PATCH v8 09/18] media: iris: Add platform flag for instantaneous bandwidth voting Dmitry Baryshkov
2026-07-30 15:20   ` [PATCH v8 10/18] media: iris: skip PIPE if it is not supported by the platform Dmitry Baryshkov
2026-07-30 15:56     ` sashiko-bot
2026-07-30 15:20   ` [PATCH v8 11/18] media: iris: Add framework support for AR50_LITE video core Dmitry Baryshkov
2026-07-30 15:41     ` sashiko-bot
2026-07-30 15:20   ` [PATCH v8 12/18] media: iris: add minimal GET_PROPERTY implementation Dmitry Baryshkov
2026-07-30 15:39     ` sashiko-bot
2026-07-30 15:20   ` [PATCH v8 13/18] media: iris: update buffer requirements based on received info Dmitry Baryshkov
2026-07-30 15:52     ` sashiko-bot
2026-07-30 15:20   ` [PATCH v8 14/18] media: iris: implement support for the Agatti platform Dmitry Baryshkov
2026-07-30 15:54     ` sashiko-bot
2026-07-30 15:20   ` [PATCH v8 15/18] media: iris: Introduce buffer size calculations for AR50LT Dmitry Baryshkov
2026-07-30 15:47     ` sashiko-bot
2026-07-30 15:20   ` [PATCH v8 16/18] media: iris: add Gen2 firmware support on the Agatti platform Dmitry Baryshkov
2026-07-30 15:21   ` [PATCH v8 17/18] media: venus: skip QCM2290 if Iris driver is enabled Dmitry Baryshkov
2026-07-30 15:39     ` sashiko-bot
2026-07-30 15:21   ` [PATCH v8 18/18] media: iris: constify inst_fw_cap_sm8250_dec Dmitry Baryshkov
2026-07-30 20:09   ` [PATCH v8 00/18] media: iris: Add AR50LT core support and enable Agatti platform Bryan O'Donoghue

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=20260730153725.A2E781F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.