提交 f5e6253f 编写于 作者: C Chunfeng Yun 提交者: Greg Kroah-Hartman

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: NChunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 b5a2a8ec
...@@ -122,6 +122,9 @@ void *hcd_buffer_alloc( ...@@ -122,6 +122,9 @@ void *hcd_buffer_alloc(
struct usb_hcd *hcd = bus_to_hcd(bus); struct usb_hcd *hcd = bus_to_hcd(bus);
int i; int i;
if (size == 0)
return NULL;
/* some USB hosts just use PIO */ /* some USB hosts just use PIO */
if (!IS_ENABLED(CONFIG_HAS_DMA) || if (!IS_ENABLED(CONFIG_HAS_DMA) ||
(!bus->controller->dma_mask && (!bus->controller->dma_mask &&
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册