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 C7B71C43334 for ; Thu, 30 Jun 2022 11:04:52 +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=yYaVeOFLnoGOeCbI4WFG9ClWl46r8KK86FwHXQ7yuL4=; b=dq+EF04U45XUyA PbPRCFY0lq4yl5KFTPceuZVRvYpZGbEWtMccH71B7IKXLkLh7bTAF/8Hh8zUIP9UmhpwSWN+Vos70 Kp4CDuZgkL/THtFwP+pP663oNm11YIgLdDkk3BR91TUYfUrS+VxYWgG4Tkj11Jto5DGnp77awzrAW fiGPg8HjByHgjiLBLPFP975ykgaM7gUgpt+3OiMHSVDpfj7qeHZzWCEkCcY2YFICJIWy30J9Imlmc qBjL3PNXJH6/pyKk9QoJM0mfsY5Ai2h5Y5G7JT6oo4F9wB90DM44oNop9HU6SrtT48lUw8M241Ci+ oAeYA5wYJIboiU56yb8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o6rxi-00GkTo-Sq; Thu, 30 Jun 2022 11:03:55 +0000 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o6rxf-00GkSm-BQ for linux-arm-kernel@lists.infradead.org; Thu, 30 Jun 2022 11:03:52 +0000 Received: by mail-pj1-x1035.google.com with SMTP id dw10-20020a17090b094a00b001ed00a16eb4so2463688pjb.2 for ; Thu, 30 Jun 2022 04:03:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=b8V7ADY+zFVOUBZ7Rju9ar4QXAaErxZ2CHOzbzSN9aU=; b=ghcVJngFT59Awjf2m+9tt7nkxAzRI7AzqoBXPWYNru3ZRPZsjKH/Ic/7qq1mtSJGfY /c+6+WG83JgVPEytgHUxTRJXf2mZoWeEH87TOzN/sPmiVZzUyDZJ3jd32XbX/GqiKvS+ p6mRm5cLKJfdpeCdErCDzbaziT19/wEIyRO3Mzh/aVQV7ak/DPCSR/u9Z70N29roPJ/A AVNbuWq5nFZ0dFlJ0ONeoByVbEuibt0y3/y4CkhCYVpefBX/wd1/vRElsKFFWkDyyY3u xNAM0NubeP4aGLIhSdnjmvotlcaiLtcet6kjSVqeKPeH4fK8+eDFX4n2pbC6r595tZLW I7ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=b8V7ADY+zFVOUBZ7Rju9ar4QXAaErxZ2CHOzbzSN9aU=; b=HnorGrFHbAw3x7nWjPGy2dO6gjuMpNhrHDrmbLx4iGt9cMio6ubpFmEXdI58I57baE s2kykg237Hs3oBVneVAGAQybOJe2kdqqNVYHG7qQwEB/O2nhUy+KyxtqXUaIE41gzfZ2 X9d42pYR8vWpCSWj4gbH61SHH36qtyJM3PJZIA7dpyRYdM8KUl8PS6YAvQm45Ye3FmSO yw0PvRCjBV/0PU/bEHjRHT3Xj9wmAfqJ3jOM1trcKTaAZ9fyUS9kEkkYZdZJKcBllbTP kmLTgkXBXpqFZ9k4F+A7PeFSMPh52NMNQuLHfTFnOlFCIi0fK/+IW/L9dCt7i4+Zokg6 keWw== X-Gm-Message-State: AJIora8nzTVE6gmehNAdw7TJNvppEVXfqDfA97/umvgXz9TvaeGTqui6 //dt5vMeG+uJn933iDZgtSn710hsPfiSUL8j X-Google-Smtp-Source: AGRyM1ukhTWAIPYaktK2CZ95Dz22JWNG1wp6pO6utXGwC8iUrqhPhxq8MXvgizcmNMtAKu/hlmW+Xw== X-Received: by 2002:a17:90a:760e:b0:1ec:83e0:3ae1 with SMTP id s14-20020a17090a760e00b001ec83e03ae1mr11095167pjk.25.1656587029967; Thu, 30 Jun 2022 04:03:49 -0700 (PDT) Received: from sebin-inspiron ([103.160.233.84]) by smtp.gmail.com with ESMTPSA id b12-20020a1709027e0c00b0016b82ff7072sm7509155plm.138.2022.06.30.04.03.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 04:03:49 -0700 (PDT) Date: Thu, 30 Jun 2022 16:33:42 +0530 From: Sebin Sebastian To: Greg Kroah-Hartman 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: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220630_040351_476771_F3EB84F7 X-CRM114-Status: GOOD ( 35.96 ) 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 08:54:04AM +0200, Greg Kroah-Hartman wrote: > 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. > After I submitted the PATCH v1, kernel test robot ran some tests and produced a report of the things that I broke while creating the patch. That's why I kept this tag. > > Signed-off-by: Sebin Sebastian > > What commit id does this change fix? > So should I provide the commit ID of the patch v1 that kernel test robot referred to? > > --- > > 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 :( > Yes, I missed the checking for ep. I thought of checking it after initilizing ep. > > - 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? > This is actually the original order that these were in. I reordered it while creating the first patch, then I changed it back to the original order they were in the source tree for this patch. > > > > - 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? > I removed the check for maxpacket because it is not initialized in this part, the check for the same thing comes after initialization. This is the check for that, this is also included in the patch. + if (maxpacket == 0 || maxpacket > ep->ep.maxpacket) { + EP_DBG(ep, "Failed, invalid EP enable param\n"); + return -EINVAL; + } Should I add the check for 'ep' in this part? > Also, your To: line is messed up somehow, please fix your email > client... > Ok, I will surely do it. > thanks, > > gre gk-h I did many mistakes in the patch v1, so I had to bring this patch to the original state things were. I left all the declarations in the same order (which made it seem like reordering) and moved the initialization part after the check for _ep and desc. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel