Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp364192iog; Wed, 29 Jun 2022 01:36:40 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sjjMKMez2Jgnvo7lY2APVBpqmMVShONJWNuFjmcXYiLANy5SGwqgSV4kai9YadRSBnim6e X-Received: by 2002:a17:907:6090:b0:722:ebd0:ce35 with SMTP id ht16-20020a170907609000b00722ebd0ce35mr2135772ejc.440.1656491800459; Wed, 29 Jun 2022 01:36:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656491800; cv=none; d=google.com; s=arc-20160816; b=auhroWMbmlYCc8S9OmwBX7K864FZUhD8ovR4Q3xoV581F00nem2rfAKEZ+1ugInLxF KYJ3Yq/olMntKoRElcyvqcMeipkhUaKBDry/7KgPGzJ+IWMkT8P3ziN6Cfbkl3wPYVDd B8CX0FxXUaBh+PQh92a57W7obp8eHjTrb8U6A1PCaQRH3Wa9nvliNs0qwwAYE/lZ2eEw 6t4ID3SuHigie3syZa5IJ8gAPLlKDtGfa81QApG3N334SkWPMdIqPTZ+htgE/cQDTRGv 5pRePhvO/mGr+vzwcIaDPFdqSg5FPSTBWF99FtbA5mLketGEvNf8Vlo6v17GlWyUT2Dc 7/mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=26ZIBRUEZIPtCeugGBeQrsgT3aaPi/jFrSW3XtqmO4E=; b=eQY8Ws5R90fJA7ostebvuArNC24EhtQueLbITHqx6VuDaDJilmbOPQuVeiiNJTpwkS 87FAXYUFfcEE9IyJw00WkEoiHW3FVWOOZ2I3BoJ0VZml/5oBff6OdeCArD+XWvECsPlL zA+zNzC5U/EEvq5Jc53V/IgaUMK188Ud//vCqo0DeqJXCXeTuTrmp6bbehAD1m9CI7mM lWtlAZdZg6vJDibEFOnLQOrpMGLX/PigTMIQ6hBUQlnKy+r5VF1s6exYRxANa4dDLJxc vjBhWUc0QAtUQpt7wZtPR5ngUJiEh+wmEegO+jQ4cauCYRCIbEllmZPyX6HhjPtU3occ FrOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20210112 header.b=LD2k1fnO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hc40-20020a17090716a800b007235c2c8a7bsi21648383ejc.855.2022.06.29.01.36.14; Wed, 29 Jun 2022 01:36:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20210112 header.b=LD2k1fnO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231298AbiF2IIA (ORCPT + 99 others); Wed, 29 Jun 2022 04:08:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231171AbiF2IH5 (ORCPT ); Wed, 29 Jun 2022 04:07:57 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 791C53BA5D; Wed, 29 Jun 2022 01:07:56 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id q18so13348717pld.13; Wed, 29 Jun 2022 01:07:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=26ZIBRUEZIPtCeugGBeQrsgT3aaPi/jFrSW3XtqmO4E=; b=LD2k1fnO3PEvw5iSj+odGBaj3uUJ/1bZXafHiHJr8dwAQMh7HAro80QefSH/JLvsY/ 9sVfjCsCTwTv1NgQt+NxnMlz9HWC6fsejYqt30mAbe9+ExgjCwO4Kmmak2r5UC6RsJCL 8KKLQeTQjogfO0ePGfWqS0wNbZHCQq3mmG1tZQTkntPEPx2ch1LPrxVCROG63Rv0w/Xf 56VD/0HfdhM9EPbPE2o0Qjsrjh4U6qLgIYafgkpLjc5IWUESAZS4q5EPhmJhUoR7Af1I 5UrMChIu5XMEHhzVLRVqnYjj24lrm6dtT1PU81wYmPPhJ09bYSI1o61PDN2VphUf/6lI EQWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=26ZIBRUEZIPtCeugGBeQrsgT3aaPi/jFrSW3XtqmO4E=; b=NDG4hEKsFpIk6twQf8NdMRFiSfAFbQlqMq1bjIVflbuuVJcDZGzH6mhn5dSQfBu82g n3XTH91X2qX3D0KYda1UUDoRrakEWZX8on6RSVQszN9SgToZpvvjgMrqwwSRltPkA3qh Sy94EJ4WW03Ln9EoR4exiRxuLQs7Y6qXY0BVnjVrnDJ82PQxMDkRxxrFHHAg5/zq4eem cm44ldW1U8QiBfvDAb3k0KdHvf3yF9KECWoWFaS0Vlygufx0d3YAiTn98wMKU9Ck45RT BWhU44Guci3bdetfwHB31n74kCWWXX4uSEbI5Taojks1EAPo9lPiwBJGSgK50GDHKrJK YLvA== X-Gm-Message-State: AJIora/t4DTEghgjSji2n9eD/ylNuLPj/t0zphrzVzXSOpicGyW93+fL KF9pBOd//hiwHMn7y1PqUW0= X-Received: by 2002:a17:90b:4b8c:b0:1ec:c7b8:7cb9 with SMTP id lr12-20020a17090b4b8c00b001ecc7b87cb9mr4345566pjb.86.1656490075939; Wed, 29 Jun 2022 01:07:55 -0700 (PDT) Received: from sebin-inspiron.bbrouter ([103.160.233.84]) by smtp.gmail.com with ESMTPSA id kk2-20020a17090b4a0200b001cd4989febcsm1398292pjb.8.2022.06.29.01.07.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 01:07:55 -0700 (PDT) From: SebinSebastian Cc: mailmesebin00@gmail.com, skhan@linuxfoundation.org, Neal Liu , Felipe Balbi , Greg Kroah-Hartman , 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: [PATCH -next] usb: gadget: dereference before null check Date: Wed, 29 Jun 2022 13:37:25 +0530 Message-Id: <20220629080726.107297-1-mailmesebin00@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SBL_CSS,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Coverity issue: 1518209 Signed-off-by: SebinSebastian --- drivers/usb/gadget/udc/aspeed_udc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/usb/gadget/udc/aspeed_udc.c b/drivers/usb/gadget/udc/aspeed_udc.c index d75a4e070bf7..96f8193fca15 100644 --- a/drivers/usb/gadget/udc/aspeed_udc.c +++ b/drivers/usb/gadget/udc/aspeed_udc.c @@ -341,10 +341,6 @@ 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); - struct ast_udc_dev *udc = ep->udc; - u8 epnum = usb_endpoint_num(desc); unsigned long flags; u32 ep_conf = 0; u8 dir_in; @@ -356,6 +352,11 @@ static int ast_udc_ep_enable(struct usb_ep *_ep, return -EINVAL; } + u16 maxpacket = usb_endpoint_maxp(desc); + struct ast_udc_ep *ep = to_ast_ep(_ep); + struct ast_udc_dev *udc = ep->udc; + u8 epnum = usb_endpoint_num(desc); + if (!udc->driver) { EP_DBG(ep, "bogus device state\n"); return -ESHUTDOWN; -- 2.34.1