From: Heiko Stuebner <heiko@sntech.de>
To: lee@kernel.org
Cc: linux-kernel@vger.kernel.org, heiko@sntech.de
Subject: [PATCH v2 1/4] mfd: qnap-mcu: Calculate the checksum on the actual number of bytes received
Date: Thu, 6 Nov 2025 00:47:01 +0100 [thread overview]
Message-ID: <20251105234704.159381-2-heiko@sntech.de> (raw)
In-Reply-To: <20251105234704.159381-1-heiko@sntech.de>
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>
---
drivers/mfd/qnap-mcu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/mfd/qnap-mcu.c b/drivers/mfd/qnap-mcu.c
index 2be429a50611..e3210541ec56 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;
}
--
2.47.2
next prev parent reply other threads:[~2025-11-05 23:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-05 23:47 [PATCH v2 0/4] Improve error handling for qnap-mcu transfers Heiko Stuebner
2025-11-05 23:47 ` Heiko Stuebner [this message]
2025-11-05 23:47 ` [PATCH v2 2/4] mfd: qnap-mcu: Use EPROTO in stead of EIO on checksum errors Heiko Stuebner
2025-11-05 23:47 ` [PATCH v2 3/4] mfd: qnap-mcu: Move checksum verification to its own function Heiko Stuebner
2025-11-05 23:47 ` [PATCH v2 4/4] mfd: qnap-mcu: Add proper error handling for command errors Heiko Stuebner
2025-11-13 16:03 ` Lee Jones
2025-11-20 10:15 ` [PATCH v2 0/4] Improve error handling for qnap-mcu transfers Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251105234704.159381-2-heiko@sntech.de \
--to=heiko@sntech.de \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox