NULL pointer dereferrence will happen when class driver
wants to allocate zero length buffer and pool_max[0]
can't be used, so skip reserved pool in this case.
Signed-off-by: Chunfeng Yun <chunfeng....@mediatek.com>
---
 drivers/usb/core/buffer.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c
index 2741566..c8f958b 100644
--- a/drivers/usb/core/buffer.c
+++ b/drivers/usb/core/buffer.c
@@ -131,7 +131,7 @@ void *hcd_buffer_alloc(
        }
 
        for (i = 0; i < HCD_BUFFER_POOLS; i++) {
-               if (size <= pool_max[i])
+               if (pool_max[i] && size <= pool_max[i])
                        return dma_pool_alloc(hcd->pool[i], mem_flags, dma);
        }
        return dma_alloc_coherent(hcd->self.controller, size, dma, mem_flags);
@@ -158,7 +158,7 @@ void hcd_buffer_free(
        }
 
        for (i = 0; i < HCD_BUFFER_POOLS; i++) {
-               if (size <= pool_max[i]) {
+               if (pool_max[i] && size <= pool_max[i]) {
                        dma_pool_free(hcd->pool[i], addr, dma);
                        return;
                }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to