[PATCH v4 3/3] i3c: master: Validate GET CCC payload length and retry Direct GET once
Alexandre Mergnat
amergnat at baylibre.com
Wed Jul 1 03:37:06 PDT 2026
On Tue, 30 Jun 2026 06:20:27 -0700, tze.yee.ng at altera.com <tze.yee.ng at altera.com> wrote:
> diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
> index 6b8df8089a35..3ad8a232340e 100644
> --- a/drivers/i3c/master.c
> +++ b/drivers/i3c/master.c
> @@ -914,17 +916,55 @@ static void i3c_ccc_cmd_dest_cleanup(struct i3c_ccc_cmd_dest *dest)
> [ ... skip 44 lines ... ]
> + continue;
> +
> + min_len = p->len - p->optional_bytes;
> + if (p->actual_len < min_len ||
> + (!p->optional_bytes && p->actual_len != p->len))
> + return -EIO;
Unless I'm misreading, the second condition looks already covered by the
checks above: when optional_bytes == 0, min_len == len, so
`actual_len < min_len` rejects anything below len while the earlier
`actual_len > len` check rejects anything above, leaving only
actual_len == len. Could `(!p->optional_bytes && p->actual_len != p->len)`
be dropped to simplify? Not a correctness concern.
> @@ -1371,19 +1437,21 @@ static int i3c_master_getmxds_locked(struct i3c_master_controller *master,
> * while expecting shorter length from this CCC command.
> */
> dest.payload.len -= 3;
Now that optional_bytes = 3 lets a 2-byte GETMXDS response pass
i3c_ccc_validate_payload_len() directly, this fallback only triggers
when the controller/device returns an error on the longer (5-byte)
request rather than a short read. Is that the intended remaining case? A
one-line note here would help; otherwise the fallback may now be
redundant.
--
Alexandre Mergnat <amergnat at baylibre.com>
More information about the linux-i3c
mailing list