Skip to content

Commit 4be3213

Browse files
Yuan Cangregkh
authored andcommitted
staging: emxx_udc: Add checks for dma_alloc_coherent()
[ Upstream commit f6510a9 ] As the dma_alloc_coherent may return NULL, the return value needs to be checked to avoid NULL poineter dereference. Signed-off-by: Yuan Can <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 6683327 commit 4be3213

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/staging/emxx_udc/emxx_udc.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2590,10 +2590,15 @@ static int nbu2ss_ep_queue(struct usb_ep *_ep,
25902590
req->unaligned = false;
25912591

25922592
if (req->unaligned) {
2593-
if (!ep->virt_buf)
2593+
if (!ep->virt_buf) {
25942594
ep->virt_buf = dma_alloc_coherent(udc->dev, PAGE_SIZE,
25952595
&ep->phys_buf,
25962596
GFP_ATOMIC | GFP_DMA);
2597+
if (!ep->virt_buf) {
2598+
spin_unlock_irqrestore(&udc->lock, flags);
2599+
return -ENOMEM;
2600+
}
2601+
}
25972602
if (ep->epnum > 0) {
25982603
if (ep->direct == USB_DIR_IN)
25992604
memcpy(ep->virt_buf, req->req.buf,

0 commit comments

Comments
 (0)