From mboxrd@z Thu Jan 1 00:00:00 1970 From: Greg KH Date: Fri, 23 Dec 2022 15:54:37 +0100 Subject: [PATCH v3] usb: gadget: aspeed_udc: Add check for dma_alloc_coherent In-Reply-To: <20221215123112.20553-1-jiasheng@iscas.ac.cn> References: <20221215123112.20553-1-jiasheng@iscas.ac.cn> Message-ID: List-Id: To: linux-aspeed@lists.ozlabs.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 at huawei.com confused, greg k-h 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 44F79C4167B for ; Fri, 23 Dec 2022 14:54:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236365AbiLWOyo (ORCPT ); Fri, 23 Dec 2022 09:54:44 -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-usb@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 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D9A59C4332F for ; Fri, 23 Dec 2022 14:56:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IVhWFtEaCvTpsHfVd9dhk71WVT0piuTPzzW+SD57FG4=; b=GXo+T2bbdza3Pw FuydHum6SGS5bnlMmg9CJ/ROKt37zn243C1C5wZI5U3ZznZq+wiCTTnKAakl4GMxngoKbGUETYVh/ AROw9TBfIk5XqGer7Ght92lrGQkhXMnAFEAsFDrVvib1AXfuLYHTrPFw22SFe1HzUG+uyy+Tq+u41 BlwGYjlkLd+6ll7pyWkLqY8FsqRgprsT1AK40okfY/HfbjNc20LjNAbQsdXf7cjLfq+6NcAJ3b7AR h+r1LInDxtK+vGkkyxTRrcoRjxKHRzqDx636/I7Tg8eezqQjcAzFvNrqrd319vay8UcfryQhruftF ctvvMQv/9VHwUDs16CZQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p8jRs-0096GB-RS; Fri, 23 Dec 2022 14:55:01 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p8jRZ-00964x-KP for linux-arm-kernel@lists.infradead.org; Fri, 23 Dec 2022 14:54:43 +0000 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 9FE0C61031; 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-Disposition: inline In-Reply-To: <20221215123112.20553-1-jiasheng@iscas.ac.cn> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221223_065441_746646_A1D0EA4F X-CRM114-Status: GOOD ( 23.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 31094C3DA79 for ; Fri, 23 Dec 2022 14:54:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5112110E1AD; Fri, 23 Dec 2022 14:54:44 +0000 (UTC) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8575910E1AD for ; Fri, 23 Dec 2022 14:54:41 +0000 (UTC) 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 9FE0C61031; 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 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> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aspeed@lists.ozlabs.org, andrew@aj.id.au, neal_liu@aspeedtech.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, sumit.semwal@linaro.org, linaro-mm-sig@lists.linaro.org, joel@jms.id.au, christian.koenig@amd.com, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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