From: Heiko Stuebner Date: Thu, 13 Nov 2025 16:52:15 +0000 (+0100) Subject: mfd: qnap-mcu: Calculate the checksum on the actual number of bytes received X-Git-Tag: v6.19-rc1~142^2~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b4881070a02b017aea84592c424d5a980ed261c4;p=thirdparty%2Fkernel%2Flinux.git 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 Link: https://patch.msgid.link/20251113165218.449616-2-heiko@sntech.de Signed-off-by: Lee Jones --- diff --git a/drivers/mfd/qnap-mcu.c b/drivers/mfd/qnap-mcu.c index 4ec1f4cf902f6..4cd5319fc6cb0 100644 --- a/drivers/mfd/qnap-mcu.c +++ b/drivers/mfd/qnap-mcu.c @@ -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; }