From: sashiko-bot@kernel.org
To: "Sergey Lebedev" <lsa.uz@pm.me>
Cc: robh@kernel.org, media-ci@linuxtv.org, conor+dt@kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH v2 3/3] media: ipu-bridge: Add Sony IMX681
Date: Wed, 09 Sep 2026 19:52:03 +0000 [thread overview]
Message-ID: <20260909195203.E1CC41F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260909193953.86192-4-lsa.uz@pm.me>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Leaked ACPI device reference and dangling secondary fwnode pointers on error paths.
--
commit 4b67afbc2a1ae41061ad9ba083bbebdbbe1112a4
Author: Sergey Lebedev <lsa.uz@pm.me>
media: ipu-bridge: Add Sony IMX681
The Microsoft Surface Pro 11 for Business (Intel Lunar Lake, IPU7) carries
a Sony IMX681 as its user-facing sensor, enumerated as ACPI device
SONY0681. Add it so ipu_bridge_connect_sensors() builds its half of the
graph; without the entry the sensor is never connected, whatever driver is
present.
> diff --git a/drivers/media/pci/intel/ipu-bridge.c b/drivers/media/pci/intel/ipu-bridge.c
> index 7e65491faf6dc..68c2eb326f1dc 100644
> --- a/drivers/media/pci/intel/ipu-bridge.c
> +++ b/drivers/media/pci/intel/ipu-bridge.c
> @@ -97,6 +97,8 @@ static const struct ipu_sensor_config ipu_supported_sensors[] = {
> IPU_SENSOR_CONFIG("OVTI5675", 1, 450000000),
> /* Omnivision OV8856 */
> IPU_SENSOR_CONFIG("OVTI8856", 3, 180000000, 360000000, 720000000),
> + /* Sony IMX681 */
> + IPU_SENSOR_CONFIG("SONY0681", 1, 969600000),
[Severity: High]
This is a pre-existing issue, but while reviewing the addition of this new
sensor, I noticed potential leaks and dangling pointers in the error handling
paths of ipu_bridge_connect_sensor() and ipu_bridge_unregister_sensors().
If ipu_bridge_instantiate_ivsc() fails:
drivers/media/pci/intel/ipu-bridge.c:ipu_bridge_connect_sensor() {
...
sensor->adev = ACPI_PTR(acpi_dev_get(adev));
primary = acpi_fwnode_handle(adev);
primary->secondary = fwnode;
ret = ipu_bridge_instantiate_ivsc(sensor);
if (ret)
goto err_free_swnodes;
...
err_free_swnodes:
software_node_unregister_node_group(sensor->group);
err_put_ivsc:
put_device(sensor->csi_dev);
acpi_dev_put(sensor->ivsc_adev);
err_put_adev:
acpi_dev_put(adev);
return ret;
}
Since bridge->n_sensors is not incremented before the failure, the caller
ipu_bridge_unregister_sensors() iterates up to the previously successful sensor
and skips this failing sensor. Does this mean the acpi_dev_get(adev) reference
held by sensor->adev is permanently leaked?
Furthermore, primary->secondary is assigned but never cleared on this error
path, leaving a dangling pointer.
Additionally, in the cleanup function itself:
drivers/media/pci/intel/ipu-bridge.c:ipu_bridge_unregister_sensors() {
for (i = 0; i < bridge->n_sensors; i++) {
sensor = &bridge->sensors[i];
software_node_unregister_node_group(sensor->group);
acpi_dev_put(sensor->adev);
put_device(sensor->csi_dev);
acpi_dev_put(sensor->ivsc_adev);
}
}
Does this code leave dangling secondary fwnode pointers? The function
unregisters and frees the software nodes, but it doesn't appear to clear the
secondary fwnode pointers on the ACPI or CSI devices first (e.g., setting
acpi_fwnode_handle(sensor->adev)->secondary = NULL or calling
set_secondary_fwnode(sensor->csi_dev, NULL)).
If the ACPI or CSI devices are later queried for fwnode properties, could
this trigger a use-after-free?
> /* Sony IMX471 */
> IPU_SENSOR_CONFIG("SONY471A", 1, 200000000),
> /* Sony IMX471 (found on Lenovo X1 Carbon G14) */
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260909193953.86192-1-lsa.uz@pm.me?part=3
prev parent reply other threads:[~2026-09-09 19:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 19:39 [PATCH v2 0/3] media: Add support for the Sony IMX681 Sergey Lebedev
2026-09-09 19:40 ` [PATCH v2 1/3] dt-bindings: media: Add " Sergey Lebedev
2026-09-09 19:40 ` [PATCH v2 2/3] media: i2c: Add Sony IMX681 sensor driver Sergey Lebedev
2026-09-09 19:52 ` sashiko-bot
2026-09-09 20:35 ` Sergey Lebedev
2026-09-09 19:40 ` [PATCH v2 3/3] media: ipu-bridge: Add Sony IMX681 Sergey Lebedev
2026-09-09 19:52 ` 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=20260909195203.E1CC41F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=lsa.uz@pm.me \
--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.