From: sashiko-bot@kernel.org
To: "Sofus Forstreuter" <sofus.c@icloud.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org,
media-ci@linuxtv.org, conor+dt@kernel.org
Subject: Re: [PATCH v2 12/17] arm64: dts: apple: t8112: add avd nodes
Date: Sat, 26 Sep 2026 13:35:38 +0000 [thread overview]
Message-ID: <20260926133539.15FDE1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260926-avd-v2-12-ecebe6a3648e@icloud.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] media: apple: null pointer dereference in avd_init_job() on allocation failure
- [High] media: apple: use-after-free of avd_ctx in avd_watchdog_func()
- [Low] media: v4l2: off-by-one error allows out-of-bounds context_update_tile_id
- [Low] dt-bindings: media: apple,avd: missing t8132 and t8140 compatible strings
--
commit 55c4cd1f1e93f6dcc1e853c4ea8a083b87538669
Author: Sofus Forstreuter <sofus.c@icloud.com>
arm64: dts: apple: t8112: add avd nodes
This patch series adds the Apple Video Decoder (AVD) driver to support
stateless video decoding on newer Apple SoCs.
> diff --git a/Documentation/devicetree/bindings/media/apple,avd.yaml b/Documentation/devicetree/bindings/media/apple,avd.yaml
> new file mode 100644
> index 0000000000000..0aa2cffae50f9
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/media/apple,avd.yaml
[ ... ]
> +properties:
> + compatible:
> + oneOf:
> + - items:
> + - enum:
> + - apple,t6030-avd
> + - apple,t6031-avd
> + - const: apple,t8122-avd
> + - enum:
> + - apple,t8103-avd
> + - apple,t8112-avd
> + - apple,t8122-avd
> + - apple,t6000-avd
> + - apple,t6020-avd
[Severity: Low]
Do the dt-bindings miss the apple,t8132-avd and apple,t8140-avd compatible
strings?
The AVD driver explicitly registers support for apple,t8132-avd and
apple,t8140-avd via the avd_of_match array in avd-drv.c.
Because the device tree binding schema documentation omits these compatible
strings, validating device trees that contain these hardware variants fails
with a dt-schema validation error.
[ ... ]
> diff --git a/drivers/media/platform/apple/avd/avd-drv.c b/drivers/media/platform/apple/avd/avd-drv.c
> new file mode 100644
> index 0000000000000..68752c44d4ec6
> --- /dev/null
> +++ b/drivers/media/platform/apple/avd/avd-drv.c
[ ... ]
> +int avd_init_job(struct avd_ctx *ctx, enum avd_codec codec, size_t segments)
> +{
> + int ret = 0;
> + struct avd_job *job = &ctx->job;
> +
> + job->codec = codec;
> + job->dest = 0x1000;
> + job->num = 0;
> + job->num_submit = 0;
> + job->num_alloc = segments;
> + ret = avd_buf_alloc(ctx->dev, &job->buf,
> + job->num_alloc * sizeof(*job->segments));
> + job->segments = job->buf.cpu;
> + memset(job->buf.cpu, 0, job->buf.size);
[Severity: High]
Is there a risk of a null pointer dereference of job->buf.cpu on allocation
failure?
If avd_buf_alloc() fails and returns -ENOMEM, it leaves job->buf.cpu as null.
Since the return value assigned to ret is not checked, the subsequent memset()
will unconditionally use the null pointer.
This path is reachable from userspace by submitting decode jobs, meaning
memory pressure could induce a kernel panic.
> + return ret;
> +}
[ ... ]
> +static void avd_watchdog_func(struct work_struct *work)
> +{
> + struct avd_dev *avd;
> + struct avd_ctx *ctx;
> + int ret;
> +
> + ctx = container_of(to_delayed_work(work), struct avd_ctx,
> + watchdog_work);
> + if (!ctx)
> + return;
> +
> + avd = ctx->dev;
[Severity: High]
Could this result in a use-after-free of ctx if it runs concurrently with
avd_release()?
In avd_release(), cancel_delayed_work() is used to stop the watchdog timer,
which doesn't block if the work is currently executing on another CPU.
Following this, avd_release() frees the context:
avd-drv.c:avd_release() {
...
cancel_delayed_work(&ctx->watchdog_work);
...
kfree(ctx);
}
If avd_watchdog_func() is running concurrently, won't it dereference the
freed ctx pointer when accessing ctx->dev?
This race condition can be triggered by closing the video device while a
decoding timeout occurs, resulting in memory corruption or a kernel panic.
[ ... ]
> +static int avd_release(struct file *filp)
> +{
> + struct avd_ctx *ctx = file_to_ctx(filp);
> +
> + cancel_delayed_work(&ctx->watchdog_work);
> +
> + v4l2_fh_del(&ctx->fh, filp);
> + v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
> + v4l2_ctrl_handler_free(&ctx->ctrl_hdl);
> + v4l2_fh_exit(&ctx->fh);
> + avd_buf_free(ctx->dev, &ctx->inst);
> + avd_buf_free(ctx->dev, &ctx->pipe_state);
> + avd_buf_free(ctx->dev, &ctx->job.buf);
> + kfree(ctx);
> +
> + return 0;
> +}
[ ... ]
> diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2-core/v4l2-ctrls-core.c
> index 9caca56478d1a..11ced5f639071 100644
> --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c
> +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c
[ ... ]
> @@ -800,10 +800,25 @@ static int validate_av1_film_grain(struct v4l2_ctrl_av1_film_grain *fg)
> return 0;
> }
>
> +static int validate_av1_tile_info(struct v4l2_av1_tile_info *ti)
> +{
> + if (ti->tile_cols > V4L2_AV1_MAX_TILE_COLS ||
> + ti->tile_rows > V4L2_AV1_MAX_TILE_ROWS)
> + return -EINVAL;
> +
> + if (ti->context_update_tile_id > ti->tile_cols * ti->tile_rows)
[Severity: Low]
Does this check allow an out-of-bounds context_update_tile_id to pass
validation?
Since context_update_tile_id is a 0-based index for the tiles, an ID exactly
equal to ti->tile_cols * ti->tile_rows is out-of-bounds.
Shouldn't this check use >= instead of > to properly enforce the AV1 bitstream
specification, which mandates that context_update_tile_id must be strictly
less than TileCols * TileRows?
This allows an invalid tile ID to be passed to hardware drivers, which could
result in undefined logic or hardware state.
> + return -EINVAL;
> +
> + return 0;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260926-avd-v2-0-ecebe6a3648e@icloud.com?part=12
next prev parent reply other threads:[~2026-09-26 13:35 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-26 13:14 [PATCH v2 00/17] media: apple: add avd driver Sofus Forstreuter
2026-09-26 13:14 ` [PATCH v2 01/17] dt-bindings: media: add apple,avd Sofus Forstreuter
2026-09-29 8:46 ` Krzysztof Kozlowski
2026-09-26 13:14 ` [PATCH v2 02/17] media: v4l2: Add P210 pixel format Sofus Forstreuter
2026-09-26 13:14 ` [PATCH v2 03/17] media: v4l2: Add Apple interchange pixel formats Sofus Forstreuter
2026-09-26 13:14 ` [PATCH v2 04/17] media: v4l2-ctrls: validate av1 tile info Sofus Forstreuter
2026-09-26 13:29 ` sashiko-bot
2026-09-26 13:14 ` [PATCH v2 05/17] media: v4l2-ctrls: validate vp9 tile_rows_log2 Sofus Forstreuter
2026-09-26 13:14 ` [PATCH v2 06/17] media: apple: add avd driver Sofus Forstreuter
2026-09-26 13:36 ` sashiko-bot
2026-09-26 13:14 ` [PATCH v2 07/17] media: apple: avd: add h264 support Sofus Forstreuter
2026-09-26 13:34 ` sashiko-bot
2026-09-26 13:14 ` [PATCH v2 08/17] media: apple: avd: add vp9 support Sofus Forstreuter
2026-09-26 13:33 ` sashiko-bot
2026-09-26 13:14 ` [PATCH v2 09/17] media: apple: avd: add hevc support Sofus Forstreuter
2026-09-26 13:35 ` sashiko-bot
2026-09-26 13:14 ` [PATCH v2 10/17] media: apple: avd: add av1 support Sofus Forstreuter
2026-09-26 13:37 ` sashiko-bot
2026-09-26 13:14 ` [PATCH v2 11/17] arm64: dts: apple: t8103: add avd nodes Sofus Forstreuter
2026-09-26 13:14 ` [PATCH v2 12/17] arm64: dts: apple: t8112: " Sofus Forstreuter
2026-09-26 13:35 ` sashiko-bot [this message]
2026-09-26 13:14 ` [PATCH v2 13/17] arm64: dts: apple: t8122: " Sofus Forstreuter
2026-09-26 13:29 ` sashiko-bot
2026-09-26 13:14 ` [PATCH v2 14/17] arm64: dts: apple: t600x: " Sofus Forstreuter
2026-09-26 13:14 ` [PATCH v2 15/17] arm64: dts: apple: t602x: " Sofus Forstreuter
2026-09-26 13:14 ` [PATCH v2 16/17] arm64: dts: apple: t6030: " Sofus Forstreuter
2026-09-26 13:34 ` sashiko-bot
2026-09-26 13:14 ` [PATCH v2 17/17] arm64: dts: apple: t6031: " Sofus Forstreuter
2026-09-26 13:35 ` sashiko-bot
2026-10-05 22:29 ` [PATCH v2 00/17] media: apple: add avd driver Neal Gompa
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=20260926133539.15FDE1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--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 \
--cc=sofus.c@icloud.com \
/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