staging: dwc2: fix thinko in dwc2_fill_host_dma_desc()
authorPaul Zimmerman <Paul.Zimmerman@synopsys.com>
Mon, 25 Nov 2013 21:42:45 +0000 (13:42 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 3 Dec 2013 16:31:08 +0000 (08:31 -0800)
The check against MAX_DMA_DESC_SIZE didn't make sense, fix it

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/dwc2/hcd_ddma.c

index 72e9788c1a13fdcd8b138c905aa2c6baba2b6c4c..3376177e4d3c0c8b1998829ae79a47dcab953a9e 100644 (file)
@@ -621,8 +621,8 @@ static void dwc2_fill_host_dma_desc(struct dwc2_hsotg *hsotg,
        struct dwc2_hcd_dma_desc *dma_desc = &qh->desc_list[n_desc];
        int len = chan->xfer_len;
 
-       if (len > MAX_DMA_DESC_SIZE)
-               len = MAX_DMA_DESC_SIZE - chan->max_packet + 1;
+       if (len > MAX_DMA_DESC_SIZE - (chan->max_packet - 1))
+               len = MAX_DMA_DESC_SIZE - (chan->max_packet - 1);
 
        if (chan->ep_is_in) {
                int num_packets;