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 --- Changelog:
v1 -> v2:
1. Add "goto err;" when allocation fails. --- drivers/usb/gadget/udc/aspeed_udc.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/drivers/usb/gadget/udc/aspeed_udc.c b/drivers/usb/gadget/udc/aspeed_udc.c index 01968e2167f9..7dc2457c7460 100644 --- a/drivers/usb/gadget/udc/aspeed_udc.c +++ b/drivers/usb/gadget/udc/aspeed_udc.c @@ -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;
On Tue, Dec 13, 2022 at 08:21:16PM +0800, Jiasheng Jiang wrote:
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
Again, please prove that you tested this and follow the requirements at: Documentation/process/researcher-guidelines.rst in order for us to be able to accept your changes.
thanks,
greg k-h
linaro-mm-sig@lists.linaro.org