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 9F038C43334 for ; Thu, 30 Jun 2022 06:55:12 +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=RwEDu4DkEXLYTboMTXqPnS0sTKiVmLvgUdgguTYeDqM=; b=iqJmRWTlgOmTjP C3l9JJk9v0rtkO7i/ns8/BAMUdU49E9JG6y4mXJLVEKRmRfIC97vq4QTjzXqbKZh1d9G6KyT4UCY2 xGjTW8PypGBPEK1R3AvcU4Pgh4NpuSYIYqoQjpS4+xF0Gy1fJ66UUC37Qqh2IaihfvqLDWIAjQ1c6 NP5rG87oE4gRghR1ZOfUDJduGFN4xhMaM5FojwW+hCUMu7lwbabCUlKl8k6r6dr+09QjnYMrqQ41U JjYXKnw/ufQzw4X24rhH+xuHiuveeAlvOaIvm8lB8zZ6vF+6q3UckQQr7Y0qCnRKEWDKxEKB2DgNy 2INizRCgk5WWXNf+yh5g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o6o4B-00FcEo-RZ; Thu, 30 Jun 2022 06:54:19 +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 1o6o46-00Fc9Y-3H for linux-arm-kernel@lists.infradead.org; Thu, 30 Jun 2022 06:54:15 +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 788E662211; Thu, 30 Jun 2022 06:54:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D5F2C34115; Thu, 30 Jun 2022 06:54:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656572047; bh=AoZZBIOZ6lxp4R1mhcbQkpMM8z6raWKSubTBxc3uKjQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JdCXLXAFdIVNttvrE3zYW5gc495EVxTjSxKY3PzJbtg3xdpmjqtTQH9IioyspcVZZ +Ur+l2PNgwu/YRulMcltk2W2KqOP8/zvvDM3bif4NooRhihc2IzocSGAbvFKOjjE/9 pqK9K2B7S2w/DbcFADGiZMhG1fjVZEzAxxzOlhdE= Date: Thu, 30 Jun 2022 08:54:04 +0200 From: Greg Kroah-Hartman To: Sebin Sebastian Cc: kernel test robot , Neal Liu , Felipe Balbi , Joel Stanley , Andrew Jeffery , linux-aspeed@lists.ozlabs.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 -next] usb: gadget: dereference before null check Message-ID: References: <20220630044706.10772-1-mailmesebin00@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220630044706.10772-1-mailmesebin00@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220629_235414_226264_F5FF6287 X-CRM114-Status: GOOD ( 20.49 ) 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, Jun 30, 2022 at 10:17:06AM +0530, Sebin Sebastian wrote: > Fix coverity warning dereferencing before null check. _ep and desc is > dereferenced on all paths until the check for null. Move the > initializations after the check for null. How can those values ever be NULL? > Coverity issue: 1518209 > > Reported-by: kernel test robot kernel test robot did not find this issue. > Signed-off-by: Sebin Sebastian What commit id does this change fix? > --- > Changes since v1: Fix the build errors and warnings due to first patch. > Fix the undeclared 'ep' and 'maxpacket' error. Fix the ISO C90 warning. > > drivers/usb/gadget/udc/aspeed_udc.c | 21 ++++++++++++++------- > 1 file changed, 14 insertions(+), 7 deletions(-) > > diff --git a/drivers/usb/gadget/udc/aspeed_udc.c b/drivers/usb/gadget/udc/aspeed_udc.c > index d75a4e070bf7..a43cf8dde2a8 100644 > --- a/drivers/usb/gadget/udc/aspeed_udc.c > +++ b/drivers/usb/gadget/udc/aspeed_udc.c > @@ -341,26 +341,33 @@ static void ast_udc_stop_activity(struct ast_udc_dev *udc) > static int ast_udc_ep_enable(struct usb_ep *_ep, > const struct usb_endpoint_descriptor *desc) > { > - u16 maxpacket = usb_endpoint_maxp(desc); > - struct ast_udc_ep *ep = to_ast_ep(_ep); checking that ep is NULL here is an impossible thing on its own. You did change this so that you didn't check this anymore, which is odd as you did not mention that in the changelog text :( > - struct ast_udc_dev *udc = ep->udc; > - u8 epnum = usb_endpoint_num(desc); > unsigned long flags; > u32 ep_conf = 0; > u8 dir_in; > u8 type; > + u16 maxpacket; > + struct ast_udc_ep *ep; > + struct ast_udc_dev *udc; > + u8 epnum; Why did you reorder these? > > - if (!_ep || !ep || !desc || desc->bDescriptorType != USB_DT_ENDPOINT || > - maxpacket == 0 || maxpacket > ep->ep.maxpacket) { > + if (!_ep || !desc || desc->bDescriptorType != USB_DT_ENDPOINT) { > EP_DBG(ep, "Failed, invalid EP enable param\n"); > return -EINVAL; > } > - Why did you remove this line? Also, your To: line is messed up somehow, please fix your email client... thanks, gre gk-h _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel