Skip to contentSkip to conversation

usb: gadget: aspeed_udc: Add checks for dma_alloc_coherent()

PATCH New Yuan Can 1 participant 1 message Nov 25, 2022

Subsystems (3)
lore
Share & tools
lore

Yuan Can

author
#0 lore raw

PATCH 1/1 usb: gadget: aspeed_udc: Add checks for dma_alloc_coherent()

As the dma_alloc_coherent() may return NULL, the return value needs to be checked to avoid NULL poineter dereference.

Fixes 055276c13205 ("usb: gadget: add Aspeed ast2600 udc driver")
---
 drivers/usb/gadget/udc/aspeed_udc.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/usb/gadget/udc/aspeed_udc.c +4 -0
index 01968e2167f9..7dc2457c7460 100644
@@ -1516,6 +1516,10 @@ 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) {
+		rc = -ENOMEM;
+		goto err;
+	}
 
 	udc->gadget.speed = USB_SPEED_UNKNOWN;
 	udc->gadget.max_speed = USB_SPEED_HIGH;
Signature · 1 line
2.17.1