diff mbox series

usb: gadget: aspeed_udc: Add check for dma_alloc_coherent

Message ID 20221213025120.23149-1-jiasheng@iscas.ac.cn
State Superseded
Headers show
Series usb: gadget: aspeed_udc: Add check for dma_alloc_coherent | expand

Commit Message

Jiasheng Jiang Dec. 13, 2022, 2:51 a.m. UTC
Add the check for the return value of dma_alloc_coherent
in order to avoid NULL pointer dereference.

Fixes: 055276c13205 ("usb: gadget: add Aspeed ast2600 udc driver")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 drivers/usb/gadget/udc/aspeed_udc.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/drivers/usb/gadget/udc/aspeed_udc.c b/drivers/usb/gadget/udc/aspeed_udc.c
index 01968e2167f9..6cf46562bb25 100644
--- a/drivers/usb/gadget/udc/aspeed_udc.c
+++ b/drivers/usb/gadget/udc/aspeed_udc.c
@@ -1516,6 +1516,8 @@  static int ast_udc_probe(struct platform_device *pdev)
 					  AST_UDC_EP_DMA_SIZE *
 					  AST_UDC_NUM_ENDPOINTS,
 					  &udc->ep0_buf_dma, GFP_KERNEL);
+	if (!udc->ep0_buf)
+		return -ENOMEM;
 
 	udc->gadget.speed = USB_SPEED_UNKNOWN;
 	udc->gadget.max_speed = USB_SPEED_HIGH;