[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260110192233.31955-1-eeodqql09@gmail.com>
Date: Sat, 10 Jan 2026 14:22:33 -0500
From: pip-izony <eeodqql09@...il.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Ingo Molnar <mingo@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>
Cc: Seungjin Bae <eeodqql09@...il.com>,
Kyungtae Kim <Kyungtae.Kim@...tmouth.edu>,
linux-usb@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] usb: r8a66597-hcd: fix potential divide-by-zero in prepare_packet_read()
From: Seungjin Bae <eeodqql09@...il.com>
The `prepare_packet_read()` function calculates the number of packets
required for a transfer by dividing the transfer buffer length by the
maximum packet size (`td->maxpacket`). The `td->maxpacket` is
initialized in `r8a66597_make_td()` function based on the endpoint
descriptor. However, it does not validate whether `td->maxpacket` is
zero before using it in the `DIV_ROUND_UP` macro.
If a malicious USB device sends a descriptor with `wMaxPacketSize` set to
0, it triggers a divide-by-zero exception (kernel panic).
Fix this by ensuring `td->maxpacket` is greater than 0 before performing
the division.
Fixes: 5d3043586db4 ("USB: r8a66597-hcd: host controller driver for R8A66597")
Signed-off-by: Seungjin Bae <eeodqql09@...il.com>
---
drivers/usb/host/r8a66597-hcd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index d21a03cf5c17..445551b4b05f 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -1097,7 +1097,7 @@ static void prepare_packet_read(struct r8a66597 *r8a66597,
pipe_start(r8a66597, td->pipe);
pipe_irq_enable(r8a66597, urb, td->pipenum);
} else {
- if (urb->actual_length == 0) {
+ if (urb->actual_length == 0 && td->maxpacket > 0) {
pipe_irq_disable(r8a66597, td->pipenum);
pipe_setting(r8a66597, td);
pipe_stop(r8a66597, td->pipe);
--
2.43.0
Powered by blists - more mailing lists