public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: accel: ethosu: Handle possible underflow in IFM size calculations
Date: Thu, 19 Feb 2026 09:57:31 +1000	[thread overview]
Message-ID: <review-patch3-20260218-ethos-fixes-v1-3-be3fa3ea9a30@kernel.org> (raw)
In-Reply-To: <20260218-ethos-fixes-v1-3-be3fa3ea9a30@kernel.org>

Patch Review

The fix changes `ifm_height` and `ifm_width` from `u32` to `s32` and adds an early check for negative values:

> -		u32 ifm_height = st->ofm.height[2] * stride_y +
> +		s32 ifm_height = st->ofm.height[2] * stride_y +
>  			st->ifm.height[2] - (st->ifm.pad_top + st->ifm.pad_bottom);
> -		u32 ifm_width  = st->ofm.width * stride_x +
> +		s32 ifm_width = st->ofm.width * stride_x +
>  			st->ifm.width - (st->ifm.pad_left + st->ifm.pad_right);
>
> +		if (ifm_height < 0 || ifm_width < 0)
> +			return -EINVAL;

The arithmetic itself is worth examining. `st->ofm.height[2]` is `u16`, `stride_y` is `u32` (max value 4), `st->ifm.height[2]` is `u16`, and `pad_top`/`pad_bottom` are `u8`. The maximum positive value is roughly `0xFFFF * 4 + 0xFFFF = 327675`, which fits comfortably in `s32`. The minimum value when padding dominates is `0 + 0 - (255 + 255) = -510`, which is representable in `s32`. So the type change is safe.

The values then get passed to `feat_matrix_length(info, &st->ifm, ifm_width, ifm_height, st->ifm.depth)` which takes `u32` parameters. Since the negative check happens before the call, only non-negative `s32` values reach the function, and the implicit conversion to `u32` is well-defined. No issues found. The commit message accurately describes the problem with padding values exceeding IFM dimensions and the mesa driver bug that triggered it.

---
Generated by Claude Code Patch Reviewer

  reply	other threads:[~2026-02-18 23:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-18 22:21 [PATCH 0/3] accel: ethosu: Runtime PM refcounting and cmd stream validation fixes Rob Herring (Arm)
2026-02-18 22:21 ` [PATCH 1/3] accel: ethosu: Fix job submit error clean-up refcount underflows Rob Herring (Arm)
2026-02-18 23:57   ` Claude review: " Claude Code Review Bot
2026-02-18 22:21 ` [PATCH 2/3] accel: ethosu: Fix NPU_OP_ELEMENTWISE validation with scalar Rob Herring (Arm)
2026-02-18 23:57   ` Claude review: " Claude Code Review Bot
2026-02-18 22:21 ` [PATCH 3/3] accel: ethosu: Handle possible underflow in IFM size calculations Rob Herring (Arm)
2026-02-18 23:57   ` Claude Code Review Bot [this message]
2026-02-18 23:57 ` Claude review: accel: ethosu: Runtime PM refcounting and cmd stream validation fixes Claude Code Review Bot

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=review-patch3-20260218-ethos-fixes-v1-3-be3fa3ea9a30@kernel.org \
    --to=claude-review@example.com \
    --cc=dri-devel-reviews@example.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