mm81x_usb_mem_read() submits a bulk IN URB for size bytes and checks only the URB status. A short transfer completes with status 0, so the function still copies size bytes from the endpoint buffer and returns size. The bytes past urb->actual_length are stale or uninitialized. The YAPS receive path and the register reads then use them as chip data. Fail the read with -EIO when the device sends fewer bytes than asked. Found while checking a report from a CodeQL-based static analysis tool that we are developing. Reproduced in a userspace harness under MemorySanitizer. Not tested on hardware. Assisted-by: LLM Fixes: b1906cea00b0 ("wifi: mm81x: add mm81x Wi-Fi HaLow driver") Signed-off-by: Maoyi Xie --- drivers/net/wireless/morsemicro/mm81x/usb.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/wireless/morsemicro/mm81x/usb.c b/drivers/net/wireless/morsemicro/mm81x/usb.c index b473a58e504f..5e6191dc3fae 100644 --- a/drivers/net/wireless/morsemicro/mm81x/usb.c +++ b/drivers/net/wireless/morsemicro/mm81x/usb.c @@ -380,6 +380,14 @@ static int mm81x_usb_mem_read(struct mm81x_usb *musb, u32 address, u8 *data, goto error; } + if (musb->endpoints[MM81X_EP_MEM_RD].urb->actual_length != size) { + dev_err(mors->dev, "short mem read %u of %zd", + musb->endpoints[MM81X_EP_MEM_RD].urb->actual_length, + size); + ret = -EIO; + goto error; + } + memcpy(data, musb->endpoints[MM81X_EP_MEM_RD].buffer, size); ret = size; -- 2.34.1