From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD348C3DA7C for ; Fri, 23 Dec 2022 14:54:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236333AbiLWOyp (ORCPT ); Fri, 23 Dec 2022 09:54:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230469AbiLWOym (ORCPT ); Fri, 23 Dec 2022 09:54:42 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 238C331DC7; Fri, 23 Dec 2022 06:54:41 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AB4F461215; Fri, 23 Dec 2022 14:54:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70414C433EF; Fri, 23 Dec 2022 14:54:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1671807280; bh=cSy0mW+JcTGb7wHmP//5AEf5hO9OkLMlS2Uwg9AqFDc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gX5Y35IKQGdNunDgzb61X+D8dOY93c74L5LknWjdD5pCpgadFrpFyVtU4rvB0RlrQ ZnZNwY2E1QprEiZCKqBLfE5KtLSI+rfB2HzIreroor7O2mDD4qFaXHOcvIMDqJGRwL FErdqywfeKrilpUbIcjoopCPLFlOle5jGZXefO5s= Date: Fri, 23 Dec 2022 15:54:37 +0100 From: Greg KH To: Jiasheng Jiang Cc: neal_liu@aspeedtech.com, joel@jms.id.au, andrew@aj.id.au, sumit.semwal@linaro.org, christian.koenig@amd.com, linux-aspeed@lists.ozlabs.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org Subject: Re: [PATCH v3] usb: gadget: aspeed_udc: Add check for dma_alloc_coherent Message-ID: References: <20221215123112.20553-1-jiasheng@iscas.ac.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221215123112.20553-1-jiasheng@iscas.ac.cn> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 15, 2022 at 08:31:12PM +0800, Jiasheng Jiang wrote: > Add the check for the return value of dma_alloc_coherent in order to > avoid NULL pointer dereference. > > This flaw was found using an experimental static analysis tool we are > developing, APP-Miner, which has not been disclosed. > > The allyesconfig build using GCC 9.3.0 shows no new warning. As we > don't have a UDC device to test with, no runtime testing was able to > be performed. > > Signed-off-by: Jiasheng Jiang > --- > Changelog: > > v2 -> v3: > > 1. Add information of finding tool and tests to commit message. > > 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; > -- > 2.25.1 > Why is this just a duplicate of the patch previously submitted here: https://lore.kernel.org/r/20221125092833.74822-1-yuancan@huawei.com confused, greg k-h