[PATCH] mei: vsc: Fix packet CRC computed over pointer size

Wentao Guan posted 1 patch 1 month, 4 weeks ago
drivers/misc/mei/vsc-tp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] mei: vsc: Fix packet CRC computed over pointer size
Posted by Wentao Guan 1 month, 4 weeks ago
vsc_tp_xfer() computes the packet CRC over sizeof(pkt) + olen bytes,
but pkt is a pointer, so sizeof(pkt) evaluates to the pointer size
instead of the size of struct vsc_tp_packet_hdr. The value correctly
match the 8-byte header on 64-bit builds.

Use sizeof(pkt->hdr), consistent with the header size used everywhere
else in the driver, e.g. in VSC_TP_PACKET_SIZE().

Fixes: 566f5ca97680 ("mei: Add transport driver for IVSC device")
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
---
 drivers/misc/mei/vsc-tp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/mei/vsc-tp.c b/drivers/misc/mei/vsc-tp.c
index 5ecf99883996b..e70c07aa0d604 100644
--- a/drivers/misc/mei/vsc-tp.c
+++ b/drivers/misc/mei/vsc-tp.c
@@ -293,7 +293,7 @@ int vsc_tp_xfer(struct vsc_tp *tp, u8 cmd, const void *obuf, size_t olen,
 	pkt->hdr.seq = cpu_to_le32(++tp->seq);
 	memcpy(pkt->buf, obuf, olen);
 
-	crc = ~crc32(~0, (u8 *)pkt, sizeof(pkt) + olen);
+	crc = ~crc32(~0, (u8 *)pkt, sizeof(pkt->hdr) + olen);
 	memcpy(pkt->buf + olen, &crc, sizeof(crc));
 
 	ret = vsc_tp_wakeup_request(tp);
-- 
2.30.2
Re: [PATCH] mei: vsc: Fix packet CRC computed over pointer size
Posted by Sakari Ailus 1 month, 4 weeks ago
Hi Wantao,

Thank you for the patch.

On Tue, Aug 04, 2026 at 04:08:42PM +0800, Wentao Guan wrote:
> vsc_tp_xfer() computes the packet CRC over sizeof(pkt) + olen bytes,
> but pkt is a pointer, so sizeof(pkt) evaluates to the pointer size
> instead of the size of struct vsc_tp_packet_hdr. The value correctly
> match the 8-byte header on 64-bit builds.
> 
> Use sizeof(pkt->hdr), consistent with the header size used everywhere
> else in the driver, e.g. in VSC_TP_PACKET_SIZE().
> 
> Fixes: 566f5ca97680 ("mei: Add transport driver for IVSC device")
> Signed-off-by: Wentao Guan <guanwentao@uniontech.com>

Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>

-- 
Kind regards,

Sakari Ailus