Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp422836imn; Wed, 3 Aug 2022 09:31:54 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tvZVCakyhjdwe0T+O6IQxgRVi+vjQV2WLdOeC7+bN9WSyTpNIHdTcyOvC3WVxqdyQfu83P X-Received: by 2002:a05:6402:5388:b0:435:71b:5d44 with SMTP id ew8-20020a056402538800b00435071b5d44mr25672545edb.364.1659544314785; Wed, 03 Aug 2022 09:31:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659544314; cv=none; d=google.com; s=arc-20160816; b=g/PDRMFR8uS653xQPd0JjBoIDNlC4vRR/Zk2FGSIPoB/fH2o7NIJrG808JRNp/j0ht uYkBK8M0hlhYAxAEwn5MYc1fvCfryoravRTdFqtSmp5HTJ+I1bo+Jd70bUg0yCQjtBWo IHv8OxfVmU6g6wolIsZD31nDjwWGCSDTydfDTmFbhn9Jj1wZkdK5cQImQeeoDD9XP+qI PMWAJVz8l8YBF5PJzFgTpkgnSBSdSjikwnCgUuaL8ovUQnNxPYr1BsGgiXYHXepIYFJ7 zfW13XLhWM1Vc2/LgLemmBKlwOgWh1VGYmCk1KF2otTjZ30tie1WkQdEMGEnAIQIx419 kb/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=9pMR6yzLDt7VOcaHBjmg259XzAkRDAK0VjYimhC2khQ=; b=E2WTgsoA7J+J3buXuPzIKgK7UOIspK6K/JYNyUzu0FzJYWjNIc+y4x77nVNsHNezdv sMfFjbrAHKVauna32PwsfdqzuZCL5BhZwkTCI3CyQA8SQJR4BU+bYUhonx4qGnt+f8tq dyjRq/zo1+JKVz9EsZaDIKcq83iN2R+VCOe+Xkqkq7hA6tkJ4a0QDswhr3g4yLKTbEMJ tmV6F9xGqWwB3dbKuFkYGkh1Q4pzwdatxealdu7vahp2PejglStEp5IOc5e/wNeMTz5M QaeGG7+UXWV3gaGoOLaQ0GpEsB7jc8w8B1Y8VbfUeecK+Me3wN+p718x9/iZ5RpFZPii J/Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oITW05rF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o11-20020a170906974b00b0073075569d05si7442541ejy.878.2022.08.03.09.31.20; Wed, 03 Aug 2022 09:31:54 -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=pass header.i=@kernel.org header.s=k20201202 header.b=oITW05rF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237671AbiHCQYj (ORCPT + 99 others); Wed, 3 Aug 2022 12:24:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233529AbiHCQYi (ORCPT ); Wed, 3 Aug 2022 12:24:38 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 476A12A276; Wed, 3 Aug 2022 09:24:37 -0700 (PDT) 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 sin.source.kernel.org (Postfix) with ESMTPS id A7AD3CE23C6; Wed, 3 Aug 2022 16:24:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0AD03C433D6; Wed, 3 Aug 2022 16:24:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659543873; bh=xGHHD9/3TQpqNCp6NqNDfgu8k1f28r0DEMxhdQ88hOI=; h=From:To:Cc:Subject:Date:From; b=oITW05rFffyqdh7e6veJZcEZfV1CIVOUxJWMZFFKDvFdPoUziqnVn//ysYqGp/WQ5 wCmKTz88cTXDKXSA0ksMruU06mWXKKUmpZKl+z8fmLTX37H1HuOkiYI6IX2pcCBnUi hOZ+h43ZRTHeSLTXGPrnVa/pBQ/KDKjb3KiC3TKVG0/RDncJdvqCTA/Zpdm/yhEQ/x eNQKJJi57GkmY2nErxiL3dBnVwJiRVf4sxUUdpfnNQ0YP1wRC2uldHhXN8KDg2nXF4 6/89YFggI0uNNW0QisvotjQNrsK6dgaOUthGyb2lx52KsECK6SGIJKaUhnSVMvUxwx 6DGibLvAfkJgg== From: Nathan Chancellor To: Greg Kroah-Hartman Cc: Peter Chen , Pawel Laszczak , Roger Quadros , Aswath Govindraju , Nick Desaulniers , Tom Rix , Andrey Strachuk , Linus Torvalds , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Nathan Chancellor Subject: [PATCH] usb: cdns3: Don't use priv_dev uninitialized in cdns3_gadget_ep_enable() Date: Wed, 3 Aug 2022 09:24:22 -0700 Message-Id: <20220803162422.2981308-1-nathan@kernel.org> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Clang warns: drivers/usb/cdns3/cdns3-gadget.c:2290:11: error: variable 'priv_dev' is uninitialized when used here [-Werror,-Wuninitialized] dev_dbg(priv_dev->dev, "usbss: invalid parameters\n"); ^~~~~~~~ include/linux/dev_printk.h:155:18: note: expanded from macro 'dev_dbg' dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__) ^~~ include/linux/dynamic_debug.h:167:7: note: expanded from macro 'dynamic_dev_dbg' dev, fmt, ##__VA_ARGS__) ^~~ include/linux/dynamic_debug.h:152:56: note: expanded from macro '_dynamic_func_call' __dynamic_func_call(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__) ^~~~~~~~~~~ include/linux/dynamic_debug.h:134:15: note: expanded from macro '__dynamic_func_call' func(&id, ##__VA_ARGS__); \ ^~~~~~~~~~~ drivers/usb/cdns3/cdns3-gadget.c:2278:31: note: initialize the variable 'priv_dev' to silence this warning struct cdns3_device *priv_dev; ^ = NULL 1 error generated. The priv_dev assignment was moved below the if statement to avoid potentially dereferencing ep before it was checked but priv_dev is used in the dev_dbg() call. To fix this, move the priv_dev and comp_desc assignments back to their original spot and hoist the ep check above those assignments with a call to pr_debug() instead of dev_dbg(). Fixes: c3ffc9c4ca44 ("usb: cdns3: change place of 'priv_ep' assignment in cdns3_gadget_ep_dequeue(), cdns3_gadget_ep_enable()") Link: https://github.com/ClangBuiltLinux/linux/issues/1680 Signed-off-by: Nathan Chancellor --- drivers/usb/cdns3/cdns3-gadget.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c index 9ac7d0a8c5da..d21b69997e75 100644 --- a/drivers/usb/cdns3/cdns3-gadget.c +++ b/drivers/usb/cdns3/cdns3-gadget.c @@ -2284,16 +2284,20 @@ static int cdns3_gadget_ep_enable(struct usb_ep *ep, int ret = 0; int val; + if (!ep) { + pr_debug("usbss: ep not configured?\n"); + return -EINVAL; + } + priv_ep = ep_to_cdns3_ep(ep); + priv_dev = priv_ep->cdns3_dev; + comp_desc = priv_ep->endpoint.comp_desc; - if (!ep || !desc || desc->bDescriptorType != USB_DT_ENDPOINT) { + if (!desc || desc->bDescriptorType != USB_DT_ENDPOINT) { dev_dbg(priv_dev->dev, "usbss: invalid parameters\n"); return -EINVAL; } - comp_desc = priv_ep->endpoint.comp_desc; - priv_dev = priv_ep->cdns3_dev; - if (!desc->wMaxPacketSize) { dev_err(priv_dev->dev, "usbss: missing wMaxPacketSize\n"); return -EINVAL; base-commit: 8288c99fc263bcafc5df5fa8c278b2eb8106364e -- 2.37.1