* usb:host: fix divide-by-zero in function fhci_queue_urb
@ 2019-04-09 14:37 zhuyan
2019-04-09 14:37 ` [PATCH] " zhuyan
2019-04-16 9:45 ` Greg Kroah-Hartman
0 siblings, 2 replies; 4+ messages in thread
From: zhuyan @ 2019-04-09 14:37 UTC (permalink / raw)
To: gregkh, anton; +Cc: linux-usb, linux-kernel, zhuyan34
In function fhci_queue_urb, the divisor of expression
(urb->transfer_buffer_length % usb_maxpacket(urb->dev, urb->pipe,
usb_pipeout(urb->pipe))) may be zero. When it is zero, unexpected results
may occur, so it is necessary to ensure that the divisor is not zero.
Signed-off-by: zhuyan <zhuyan34@huawei.com>
---
drivers/usb/host/fhci-sched.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/host/fhci-sched.c b/drivers/usb/host/fhci-sched.c
index 3d12cdd..27ed63c 100644
--- a/drivers/usb/host/fhci-sched.c
+++ b/drivers/usb/host/fhci-sched.c
@@ -704,6 +704,7 @@ void fhci_queue_urb(struct fhci_hcd *fhci, struct urb *urb)
struct td *td;
u8 *data;
u16 cnt = 0;
+ u16 max_pkt_size = 0;
if (ed == NULL) {
ed = fhci_get_empty_ed(fhci);
@@ -765,11 +766,13 @@ void fhci_queue_urb(struct fhci_hcd *fhci, struct urb *urb)
switch (ed->mode) {
case FHCI_TF_BULK:
+ max_pkt_size = usb_maxpacket(urb->dev, urb->pipe,
+ usb_pipeout(urb->pipe));
if (urb->transfer_flags & URB_ZERO_PACKET &&
urb->transfer_buffer_length > 0 &&
+ (max_pkt_size != 0) &&
((urb->transfer_buffer_length %
- usb_maxpacket(urb->dev, urb->pipe,
- usb_pipeout(urb->pipe))) == 0))
+ max_pkt_size) == 0))
urb_state = US_BULK0;
while (data_len > 4096) {
td = fhci_td_fill(fhci, urb, urb_priv, ed, cnt,
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] usb:host: fix divide-by-zero in function fhci_queue_urb
2019-04-09 14:37 usb:host: fix divide-by-zero in function fhci_queue_urb zhuyan
@ 2019-04-09 14:37 ` zhuyan
2019-04-16 9:45 ` Greg Kroah-Hartman
1 sibling, 0 replies; 4+ messages in thread
From: zhuyan @ 2019-04-09 14:37 UTC (permalink / raw)
To: gregkh, anton; +Cc: linux-usb, linux-kernel, zhuyan34
In function fhci_queue_urb, the divisor of expression
(urb->transfer_buffer_length % usb_maxpacket(urb->dev, urb->pipe,
usb_pipeout(urb->pipe))) may be zero. When it is zero, unexpected results
may occur, so it is necessary to ensure that the divisor is not zero.
Signed-off-by: zhuyan <zhuyan34@huawei.com>
---
drivers/usb/host/fhci-sched.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/host/fhci-sched.c b/drivers/usb/host/fhci-sched.c
index 3d12cdd..27ed63c 100644
--- a/drivers/usb/host/fhci-sched.c
+++ b/drivers/usb/host/fhci-sched.c
@@ -704,6 +704,7 @@ void fhci_queue_urb(struct fhci_hcd *fhci, struct urb *urb)
struct td *td;
u8 *data;
u16 cnt = 0;
+ u16 max_pkt_size = 0;
if (ed == NULL) {
ed = fhci_get_empty_ed(fhci);
@@ -765,11 +766,13 @@ void fhci_queue_urb(struct fhci_hcd *fhci, struct urb *urb)
switch (ed->mode) {
case FHCI_TF_BULK:
+ max_pkt_size = usb_maxpacket(urb->dev, urb->pipe,
+ usb_pipeout(urb->pipe));
if (urb->transfer_flags & URB_ZERO_PACKET &&
urb->transfer_buffer_length > 0 &&
+ (max_pkt_size != 0) &&
((urb->transfer_buffer_length %
- usb_maxpacket(urb->dev, urb->pipe,
- usb_pipeout(urb->pipe))) == 0))
+ max_pkt_size) == 0))
urb_state = US_BULK0;
while (data_len > 4096) {
td = fhci_td_fill(fhci, urb, urb_priv, ed, cnt,
--
1.8.5.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* usb:host: fix divide-by-zero in function fhci_queue_urb
@ 2019-04-16 9:45 ` Greg Kroah-Hartman
2019-04-16 9:45 ` [PATCH] " Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2019-04-16 9:45 UTC (permalink / raw)
To: zhuyan; +Cc: anton, linux-usb, linux-kernel
On Tue, Apr 09, 2019 at 10:37:12PM +0800, zhuyan wrote:
> In function fhci_queue_urb, the divisor of expression
> (urb->transfer_buffer_length % usb_maxpacket(urb->dev, urb->pipe,
> usb_pipeout(urb->pipe))) may be zero.
How can you hit that?
> When it is zero, unexpected results may occur, so it is necessary to
> ensure that the divisor is not zero.
>
> Signed-off-by: zhuyan <zhuyan34@huawei.com>
I need a "Full" name here, not just a single name. Whatever you use to
sign documents is good.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] usb:host: fix divide-by-zero in function fhci_queue_urb
2019-04-16 9:45 ` Greg Kroah-Hartman
@ 2019-04-16 9:45 ` Greg KH
0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2019-04-16 9:45 UTC (permalink / raw)
To: zhuyan; +Cc: anton, linux-usb, linux-kernel
On Tue, Apr 09, 2019 at 10:37:12PM +0800, zhuyan wrote:
> In function fhci_queue_urb, the divisor of expression
> (urb->transfer_buffer_length % usb_maxpacket(urb->dev, urb->pipe,
> usb_pipeout(urb->pipe))) may be zero.
How can you hit that?
> When it is zero, unexpected results may occur, so it is necessary to
> ensure that the divisor is not zero.
>
> Signed-off-by: zhuyan <zhuyan34@huawei.com>
I need a "Full" name here, not just a single name. Whatever you use to
sign documents is good.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-04-16 9:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-09 14:37 usb:host: fix divide-by-zero in function fhci_queue_urb zhuyan
2019-04-09 14:37 ` [PATCH] " zhuyan
2019-04-16 9:45 ` Greg Kroah-Hartman
2019-04-16 9:45 ` [PATCH] " Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).