aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/core/buffer.c
diff options
context:
space:
mode:
authorChunfeng Yun <chunfeng.yun@mediatek.com>2016-04-27 23:42:20 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-04-28 15:35:36 -0400
commitf5e6253fe6de35fc2fa059974dbd9d61f32e4cd0 (patch)
treef2aea215554ff4c40edde5f7ebe807c2ce60d636 /drivers/usb/core/buffer.c
parentb5a2a8ecb204c821f47b43ab7e93f408b0d085b1 (diff)
usb: core: buffer: avoid NULL pointer dereferrence
NULL pointer dereferrence will happen when class driver wants to allocate zero length buffer and pool_max[0] can't be used, so simply returns NULL in the case. Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/core/buffer.c')
-rw-r--r--drivers/usb/core/buffer.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c
index 2741566ee4f2..98e39f91723a 100644
--- a/drivers/usb/core/buffer.c
+++ b/drivers/usb/core/buffer.c
@@ -122,6 +122,9 @@ void *hcd_buffer_alloc(
122 struct usb_hcd *hcd = bus_to_hcd(bus); 122 struct usb_hcd *hcd = bus_to_hcd(bus);
123 int i; 123 int i;
124 124
125 if (size == 0)
126 return NULL;
127
125 /* some USB hosts just use PIO */ 128 /* some USB hosts just use PIO */
126 if (!IS_ENABLED(CONFIG_HAS_DMA) || 129 if (!IS_ENABLED(CONFIG_HAS_DMA) ||
127 (!bus->controller->dma_mask && 130 (!bus->controller->dma_mask &&