Linux USB
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Matti Paksula" <matti.paksula@gmail.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH] usb: typec: ucsi: clamp returned message length to buffer size
Date: Sun, 06 Dec 2026 10:22:49 +0000	[thread overview]
Message-ID: <sashiko-outbox-252355@kernel.org> (raw)
In-Reply-To: <20261206100349.15-1-matti.paksula@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] usb: typec: ucsi: changelog overstates EPR guard in
  ucsi_psy_get_voltage_now()
--

commit d79e541be7b6f8eb79ed53d7ac0f79ab1feb4722
Author: Matti Paksula <matti.paksula@gmail.com>

usb: typec: ucsi: clamp returned message length to buffer size

This commit clamps the length returned by ucsi_run_command() to the caller's
buffer size when a destination buffer is provided, and adds an upper bound
check against con->num_pdos in ucsi_psy_get_voltage_now().

> Clamp the length returned by ucsi_run_command() to `size` whenever a
> destination buffer `data` was supplied, so callers never observe more
> bytes than were actually copied into `data`. Also guard `index <=
> con->num_pdos` in ucsi_psy_get_voltage_now() so an RDO object position
> beyond the stored PDOs (both during port registration before
> ucsi_get_src_pdos() has populated con->src_pdos, and for EPR object
> positions > 7) cannot index past valid entries in `con->src_pdos`.

[Severity: Low]
Is the commit message accurate about guarding EPR object positions > 7?

In include/linux/usb/pd.h, rdo_index() masks with RDO_OBJ_POS_MASK (0x7), so
it only returns 0..7.  For USB PD 3.1+ EPR contracts, 4-bit positions 9..13
have bit 31 truncated and wrap to 1..5, still passing index <= con->num_pdos
and reporting the wrong SPR PDO voltage instead of 0.

Consider rewording the changelog so it does not claim that EPR object
positions > 7 are currently caught by this check.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261206100349.15-1-matti.paksula@gmail.com?part=1

      reply	other threads:[~2026-12-06 10:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-06 10:03 [PATCH] usb: typec: ucsi: clamp returned message length to buffer size Matti Paksula
2026-12-06 10:22 ` 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=sashiko-outbox-252355@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=matti.paksula@gmail.com \
    --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