Re: [PATCH v4 3/3] i3c: master: Validate GET CCC payload length and retry Direct GET once
"NG, TZE YEE" <[email protected]> Fri, 3 Jul 2026 09:16:23 +0000
| Newsgroups | org.infradead.lists.linux-i3c,dev.linux.lists.imx,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On 1/7/2026 6:37 pm, Alexandre Mergnat wrote: > [You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ] > > On Tue, 30 Jun 2026 06:20:27 -0700, [email protected] <[email protected]> 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. > Hi Alexandre, Agreed — you read it correctly. When optional_bytes == 0, min_len == len and the surrounding checks already leave only actual_len == len. I will drop the redundant condition in v5. >> @@ -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 <[email protected]> Yes — with optional_bytes = 3, a 2-byte success on the first attempt no longer needs the fallback. It remains for when the 5-byte request fails rather than returning a short read. I will add a clarifying comment in v5. Thanks, Tze Yee -- linux-i3c mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-i3c