]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
usb: misc: usbtest: fix error of urb allocation
authorChunfeng Yun <chunfeng.yun@mediatek.com>
Thu, 28 Apr 2016 03:42:21 +0000 (11:42 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Apr 2016 19:35:36 +0000 (12:35 -0700)
urb allocation will fail when usbtest_alloc_urb() tries to
allocate zero length buffer, but it doesn't need it in fact,
so just skips buffer allocation in the case.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/misc/usbtest.c

index 92fdb6e9faff4003a157ea742a2193e869d06519..de485d8a5beb8557443538a630e506cae545f2c7 100644 (file)
@@ -287,6 +287,9 @@ static struct urb *usbtest_alloc_urb(
        if (usb_pipein(pipe))
                urb->transfer_flags |= URB_SHORT_NOT_OK;
 
+       if ((bytes + offset) == 0)
+               return urb;
+
        if (urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)
                urb->transfer_buffer = usb_alloc_coherent(udev, bytes + offset,
                        GFP_KERNEL, &urb->transfer_dma);