Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f5e6253f authored by Chunfeng Yun's avatar Chunfeng Yun Committed by Greg Kroah-Hartman
Browse files

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: default avatarChunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b5a2a8ec
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -122,6 +122,9 @@ void *hcd_buffer_alloc(
	struct usb_hcd		*hcd = bus_to_hcd(bus);
	int			i;

	if (size == 0)
		return NULL;

	/* some USB hosts just use PIO */
	if (!IS_ENABLED(CONFIG_HAS_DMA) ||
	    (!bus->controller->dma_mask &&