linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: core: buffer: avoid NULL pointer dereferrence
@ 2016-04-08  9:08 Chunfeng Yun
  2016-04-08 14:07 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 9+ messages in thread
From: Chunfeng Yun @ 2016-04-08  9:08 UTC (permalink / raw)
  To: linux-arm-kernel

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.yun@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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-04-27  1:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-08  9:08 [PATCH] usb: core: buffer: avoid NULL pointer dereferrence Chunfeng Yun
2016-04-08 14:07 ` Greg Kroah-Hartman
2016-04-08 15:21   ` Alan Stern
2016-04-26 23:11     ` Greg Kroah-Hartman
2016-04-27  1:32       ` chunfeng yun
2016-04-11  3:01   ` chunfeng yun
2016-04-11  5:07     ` Felipe Balbi
2016-04-11  7:16       ` chunfeng yun
2016-04-11  8:24         ` Felipe Balbi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).