1
0

mfd: qnap-mcu: Calculate the checksum on the actual number of bytes received

In the case of an error message, the number of received bytes can be
less than originally expected but still contain a valid message.

If the transfer itself ended in an error we would exit earlier already.

So calculate the checksum on the number of received bytes and not the
number of expected bytes.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Link: https://patch.msgid.link/20251113165218.449616-2-heiko@sntech.de
Signed-off-by: Lee Jones <lee@kernel.org>
This commit is contained in:
Heiko Stuebner
2025-11-13 17:52:15 +01:00
committed by Lee Jones
parent 46bddb5fbe
commit b4881070a0

View File

@@ -175,8 +175,8 @@ int qnap_mcu_exec(struct qnap_mcu *mcu,
return -ETIMEDOUT;
}
crc = qnap_mcu_csum(rx, reply_data_size);
if (crc != rx[reply_data_size]) {
crc = qnap_mcu_csum(rx, reply->received - QNAP_MCU_CHECKSUM_SIZE);
if (crc != rx[reply->received - QNAP_MCU_CHECKSUM_SIZE]) {
dev_err(&mcu->serdev->dev, "Invalid Checksum received\n");
return -EIO;
}