From: Khalid Masum <khalid.masum.92@gmail.com>
To: Alan Stern <stern@rowland.harvard.edu>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Khalid Masum <khalid.masum.92@gmail.com>
Subject: [PATCH 2/2] usb: ehci: Prevent possible modulo by zero
Date: Wed, 24 Aug 2022 00:27:58 +0600 [thread overview]
Message-ID: <20220823182758.13401-3-khalid.masum.92@gmail.com> (raw)
In-Reply-To: <20220823182758.13401-1-khalid.masum.92@gmail.com>
usb_maxpacket() returns 0 if it fails to fetch the endpoint. This
value is later used for calculating modulo. Which can cause modulo
by zero in qtd_fill.
Prevent this breakage by returning if maxpacket is found to be 0.
Fixes coverity warning: 1487371 ("Division or modulo by zero")
Fixes: 9841f37a1cca ("usb: ehci: Add support for SINGLE_STEP_SET_FEATURE test of EHSET")
Signed-off-by: Khalid Masum <khalid.masum.92@gmail.com>
---
drivers/usb/host/ehci-q.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index eb31d13e9ecd..cf2585e9a09f 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -1221,6 +1221,8 @@ static int ehci_submit_single_step_set_feature(
token |= (1 /* "in" */ << 8); /*This is IN stage*/
maxpacket = usb_maxpacket(urb->dev, urb->pipe);
+ if (unlikely(!maxpacket))
+ return -1;
qtd_fill(ehci, qtd, buf, len, token, maxpacket);
--
2.37.1
next prev parent reply other threads:[~2022-08-23 19:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-23 18:27 [PATCH 0/2] usb: ehci: Prevent possible modulo by zero Khalid Masum
2022-08-23 18:27 ` [PATCH 1/2] " Khalid Masum
2022-08-23 20:21 ` Alan Stern
2022-08-24 11:15 ` Khalid Masum
2022-08-24 14:38 ` Alan Stern
2022-08-24 18:07 ` Khalid Masum
2022-08-23 18:27 ` Khalid Masum [this message]
2022-08-24 5:56 ` [PATCH 2/2] " Greg Kroah-Hartman
2022-08-24 11:22 ` Khalid Masum
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=20220823182758.13401-3-khalid.masum.92@gmail.com \
--to=khalid.masum.92@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/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