* [PATCH v2 1/2] usb: core: buffer: avoid NULL pointer dereferrence
@ 2016-04-28 3:42 Chunfeng Yun
2016-04-28 3:42 ` [PATCH v2 2/2] usb: misc: usbtest: fix error of urb allocation Chunfeng Yun
0 siblings, 1 reply; 2+ messages in thread
From: Chunfeng Yun @ 2016-04-28 3:42 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Chunfeng Yun, linux-kernel, linux-arm-kernel, linux-usb,
linux-mediatek, Felipe Balbi, Alan Stern
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>
---
drivers/usb/core/buffer.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c
index 2741566..98e39f9 100644
--- a/drivers/usb/core/buffer.c
+++ b/drivers/usb/core/buffer.c
@@ -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 &&
--
1.7.9.5
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH v2 2/2] usb: misc: usbtest: fix error of urb allocation
2016-04-28 3:42 [PATCH v2 1/2] usb: core: buffer: avoid NULL pointer dereferrence Chunfeng Yun
@ 2016-04-28 3:42 ` Chunfeng Yun
0 siblings, 0 replies; 2+ messages in thread
From: Chunfeng Yun @ 2016-04-28 3:42 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Chunfeng Yun, linux-kernel, linux-arm-kernel, linux-usb,
linux-mediatek, Felipe Balbi, Alan Stern
urb allocation will fail when usbtest_alloc_urb() tries to
allocate zero length buffer, but it doesn't need it in fact,
so just skips buffer allocation in the case.
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
drivers/usb/misc/usbtest.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 92fdb6e..de485d8 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -287,6 +287,9 @@ static struct urb *usbtest_alloc_urb(
if (usb_pipein(pipe))
urb->transfer_flags |= URB_SHORT_NOT_OK;
+ if ((bytes + offset) == 0)
+ return urb;
+
if (urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)
urb->transfer_buffer = usb_alloc_coherent(udev, bytes + offset,
GFP_KERNEL, &urb->transfer_dma);
--
1.7.9.5
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-04-28 3:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-28 3:42 [PATCH v2 1/2] usb: core: buffer: avoid NULL pointer dereferrence Chunfeng Yun
2016-04-28 3:42 ` [PATCH v2 2/2] usb: misc: usbtest: fix error of urb allocation Chunfeng Yun
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®