From: Jamin Lin <jamin_lin@aspeedtech.com>
To: "jithu.joseph@oss.qualcomm.com" <jithu.joseph@oss.qualcomm.com>,
"clg@kaod.org" <clg@kaod.org>,
"nabihestefan@google.com" <nabihestefan@google.com>,
"komlodi@google.com" <komlodi@google.com>,
"open list:All patches CC here" <qemu-devel@nongnu.org>
Cc: Jamin Lin <jamin_lin@aspeedtech.com>,
Troy Lee <troy_lee@aspeedtech.com>,
Kane Chen <kane_chen@aspeedtech.com>
Subject: [PATCH v1 3/4] hw/i3c/core: Initialize num_sent in i3c_send_byte()
Date: Mon, 2 Mar 2026 03:26:33 +0000 [thread overview]
Message-ID: <20260302032626.1974743-4-jamin_lin@aspeedtech.com> (raw)
In-Reply-To: <20260302032626.1974743-1-jamin_lin@aspeedtech.com>
i3c_send_byte() declared num_sent without initializing it before
passing its address to i3c_send().
Although i3c_send_byte() itself ignores num_sent after the call,
i3c_send() forwards it to trace_i3c_send(). If the target send
callback does not set *num_sent, the trace may print an
uninitialized value, leading to misleading or garbage output.
Example concern from review:
trace_i3c_send(*num_sent, num_to_send, ret == 0);
If *num_sent is not written by the callback, this trace can report
an incorrect number of transmitted bytes.
Initialize num_sent to 0 to ensure deterministic and predictable
trace output, even if the callback fails to update it.
Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
---
hw/i3c/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/i3c/core.c b/hw/i3c/core.c
index 0a266e00a2..168526003d 100644
--- a/hw/i3c/core.c
+++ b/hw/i3c/core.c
@@ -325,7 +325,7 @@ int i3c_send_byte(I3CBus *bus, uint8_t data)
* Ignored, the caller can determine how many were sent based on if this was
* ACKed/NACKed.
*/
- uint32_t num_sent;
+ uint32_t num_sent = 0;
return i3c_send(bus, &data, 1, &num_sent);
}
--
2.43.0
next prev parent reply other threads:[~2026-03-02 3:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-02 3:26 [PATCH v1 0/4] hw/i3c: Trace fixes and readability improvements from review feedback Jamin Lin
2026-03-02 3:26 ` [PATCH v1 1/4] hw/i3c/dw-i3c: Use ROUND_UP() for RX buffer allocation alignment Jamin Lin
2026-03-02 21:46 ` Jithu Joseph
2026-03-02 3:26 ` [PATCH v1 2/4] hw/i3c/mock-i3c-target: Set num_sent in TX callback to fix trace reporting Jamin Lin
2026-03-02 21:38 ` Jithu Joseph
2026-03-03 1:17 ` Jamin Lin
2026-03-02 3:26 ` Jamin Lin [this message]
2026-03-02 22:44 ` [PATCH v1 3/4] hw/i3c/core: Initialize num_sent in i3c_send_byte() Jithu Joseph
2026-03-02 3:26 ` [PATCH v1 4/4] hw/i3c/mock-i3c-target: Simplify GETMRL byte extraction logic Jamin Lin
2026-03-03 0:00 ` Jithu Joseph
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=20260302032626.1974743-4-jamin_lin@aspeedtech.com \
--to=jamin_lin@aspeedtech.com \
--cc=clg@kaod.org \
--cc=jithu.joseph@oss.qualcomm.com \
--cc=kane_chen@aspeedtech.com \
--cc=komlodi@google.com \
--cc=nabihestefan@google.com \
--cc=qemu-devel@nongnu.org \
--cc=troy_lee@aspeedtech.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.