OSDN Git Service

usb: isp1760: check maxpacketsize before using it
authorRui Miguel Silva <rui.silva@linaro.org>
Thu, 19 Aug 2021 18:09:26 +0000 (19:09 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 26 Aug 2021 11:30:39 +0000 (13:30 +0200)
When checking if we need one more packet on a bulk pipe we may, even
though not probable at all, get there with a zero maxpacketsize.
In that case for sure no packet, no even a one more, will be
allocated.

This will clean the clang-analyzer warning:
drivers/usb/isp1760/isp1760-hcd.c:1856:38: warning: Division by zero [clang-analyzer-core.DivideZero]
                                && !(urb->transfer_buffer_length %

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Link: https://lore.kernel.org/r/20210819180929.1327349-3-rui.silva@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/isp1760/isp1760-hcd.c

index 2a21fe5..5c947a1 100644 (file)
@@ -1854,7 +1854,7 @@ static void packetize_urb(struct usb_hcd *hcd,
                                packet_type = OUT_PID;
                        else
                                packet_type = IN_PID;
-               } else if (usb_pipebulk(urb->pipe)
+               } else if (usb_pipebulk(urb->pipe) && maxpacketsize
                                && (urb->transfer_flags & URB_ZERO_PACKET)
                                && !(urb->transfer_buffer_length %
                                                        maxpacketsize)) {