* [PATCH] mfd: iqs62x: reject zero-length firmware records
@ 2026-07-06 9:10 Pengpeng Hou
2026-07-16 11:40 ` Lee Jones
0 siblings, 1 reply; 2+ messages in thread
From: Pengpeng Hou @ 2026-07-06 9:10 UTC (permalink / raw)
To: Lee Jones; +Cc: Pengpeng, mfd, linux-kernel
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>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mfd: iqs62x: reject zero-length firmware records
2026-07-06 9:10 [PATCH] mfd: iqs62x: reject zero-length firmware records Pengpeng Hou
@ 2026-07-16 11:40 ` Lee Jones
0 siblings, 0 replies; 2+ messages in thread
From: Lee Jones @ 2026-07-16 11:40 UTC (permalink / raw)
To: Pengpeng Hou; +Cc: mfd, linux-kernel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-16 11:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-06 9:10 [PATCH] mfd: iqs62x: reject zero-length firmware records Pengpeng Hou
2026-07-16 11:40 ` Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox