Re: [PATCH] bus: mhi: ep: Update read pointer only after buffer is written

From: Jeff Hugo
Date: Wed Apr 09 2025 - 10:46:54 EST


On 4/9/2025 4:47 AM, Sumit Kumar wrote:
Inside mhi_ep_ring_add_element, the read pointer (rd_offset) is updated
before the buffer is written, potentially causing race conditions where
the host sees an updated read pointer before the buffer is actually
written. Updating rd_offset prematurely can lead to the host accessing
an uninitialized or incomplete element, resulting in data corruption.

Invoke the buffer write before updating rd_offset to ensure the element
is fully written before signaling its availability.

Fixes: bbdcba57a1a2 ("bus: mhi: ep: Add support for ring management")
cc: stable@xxxxxxxxxxxxxxx
Co-developed-by: Youssef Samir <quic_yabdulra@xxxxxxxxxxx>
Signed-off-by: Youssef Samir <quic_yabdulra@xxxxxxxxxxx>
Signed-off-by: Sumit Kumar <quic_sumk@xxxxxxxxxxx>

Reviewed-by: Jeff Hugo <jeff.hugo@xxxxxxxxxxxxxxxx>