From: Lee Jones <lee@kernel.org>
To: Pengpeng Hou <pengpeng@iscas.ac.cn>
Cc: mfd@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mfd: iqs62x: reject zero-length firmware records
Date: Thu, 16 Jul 2026 12:40:29 +0100 [thread overview]
Message-ID: <20260716114029.GC1260374@google.com> (raw)
In-Reply-To: <20260706091034.75865-1-pengpeng@iscas.ac.cn>
On Mon, 06 Jul 2026, Pengpeng Hou wrote:
> From: Pengpeng <pengpeng@iscas.ac.cn>
>
> The IQS62x firmware parser treats the first data byte as part of
> struct iqs62x_fw_rec and advances by len - 1 after the fixed record
> header. A zero length record would underflow that arithmetic and leave
> later type-specific reads without a valid current record payload.
>
> Reject zero-length records and compare the declared tail length against
> the remaining firmware bytes without open-coded subtraction on the
> cursor.
>
> Signed-off-by: Pengpeng <pengpeng@iscas.ac.cn>
Nit: Your Author and Signed-off-by tags should use your full name.
> ---
> drivers/mfd/iqs62x.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mfd/iqs62x.c b/drivers/mfd/iqs62x.c
> index ee017617d1d1..412ae7777f72 100644
> --- a/drivers/mfd/iqs62x.c
> +++ b/drivers/mfd/iqs62x.c
> @@ -237,7 +237,7 @@ static int iqs62x_firmware_parse(struct iqs62x_core *iqs62x,
> fw_rec = (struct iqs62x_fw_rec *)(fw->data + pos);
> pos += sizeof(*fw_rec);
>
> - if (pos + fw_rec->len - 1 > fw->size) {
> + if (!fw_rec->len || fw_rec->len - 1 > fw->size - pos) {
> ret = -EINVAL;
> break;
> }
> --
> 2.43.0
>
--
Lee Jones
prev parent reply other threads:[~2026-07-16 11:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 9:10 [PATCH] mfd: iqs62x: reject zero-length firmware records Pengpeng Hou
2026-07-16 11:40 ` Lee Jones [this message]
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=20260716114029.GC1260374@google.com \
--to=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mfd@lists.linux.dev \
--cc=pengpeng@iscas.ac.cn \
/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