Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1855634rwb; Fri, 19 Aug 2022 10:30:24 -0700 (PDT) X-Google-Smtp-Source: AA6agR6FpHEya6zk1wDY0ObBW9Og7+qeEhYHjLxRu5yr1WfuI6N7N5MLiiYubKdfLAsUKgweJqTt X-Received: by 2002:a17:90b:3141:b0:1f7:75cf:a449 with SMTP id ip1-20020a17090b314100b001f775cfa449mr9334786pjb.18.1660930224534; Fri, 19 Aug 2022 10:30:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660930224; cv=none; d=google.com; s=arc-20160816; b=SUlXysUp/LcSrwLiG4BADGnBAvkYC6QM4q0raSkhGpiubQ+Ug9dLpsNgxGocpeFJTL U0qbU77lklsAhcm5AJ+ukGgO2tXgnbPOO0OOhLK+Fz59ssOwo521PluRDn7eURWmEbZf 2ueIibgx4BHfZkSOJTpqwg3hyitw7XeW1r2Nus6VXmIn9kFDxeKIcV3JdcSAPWknFqDr mxlKlapvvlf+jfy794W4YhoyI4EEJ/zCwq/zTKTf0poT+RRROniXGlTue/xSCjafZmIS 09C4Q6ja6udGJr0NOm+podcCFW1JtwS3D624O6UcXOZG2lKfUzrmZSib0VLo3DZWAgJ+ EqRQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rlo7tVupB4PAHIwBC11n2rGeJPdgTYiHJafL4fS6oJM=; b=GAWuoRPS4DyOaVrYT4xMSc6cD9gBdwMbDuW1WA4obos6stK4IrnzMw8p5toGSwHbqt TpWGv36GlZBy2jHlcZWHW+r0SnRhlUPNQdwuBeolr0wwNOWPoYyGCq01TFBv3Xpp/pQn 0nFly5oXImBrfxsLZwOJu6KMEg3gvjPZf+JxAJRMZYOsmz3GS+CA7NATq01YQUFnPkV+ /6ZjZb9B/lKhqWn1cmpd2TdLxeNydo1IU5gIRSVYdwkpeV8VGnP0J6GzSFdgcFB4RMyk qTn8SL81Ee6C0EtbMLakazKcqIne5L2Ut/l4yZUS+JYwvdUtlFB8yMY+Qi/S0Q3uIb9K t00w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=eeThMjRj; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e65-20020a636944000000b0041e1bbc16a8si4335052pgc.608.2022.08.19.10.30.13; Fri, 19 Aug 2022 10:30:24 -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=@linuxfoundation.org header.s=korg header.b=eeThMjRj; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352940AbiHSQ3Z (ORCPT + 99 others); Fri, 19 Aug 2022 12:29:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353097AbiHSQ0M (ORCPT ); Fri, 19 Aug 2022 12:26:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29B60118C97; Fri, 19 Aug 2022 09:03:56 -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 dfw.source.kernel.org (Postfix) with ESMTPS id D52EC617F1; Fri, 19 Aug 2022 16:03:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA1DEC43140; Fri, 19 Aug 2022 16:03:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660925035; bh=WDNnPOBERHt5+eoDNxGRACSNg3dxrCW6GtFXzhVsNRc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eeThMjRjat89SNSNTph0TBswNfABU4eO6ePxvBrly874Cc3CmxChMD0tLKn5+W5kL nNEO+HTEiIoRLL9N708q28C4OZCtohcOzg8rMR2UCT4w6XsDLhcGpIm7s3qdRmbl56 5MeqTwsdrXML+agmmuPgI4OxsbS+KCgyvqYL9tyo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nathan Chancellor , Linus Torvalds , Sasha Levin Subject: [PATCH 5.10 362/545] usb: cdns3: Dont use priv_dev uninitialized in cdns3_gadget_ep_enable() Date: Fri, 19 Aug 2022 17:42:12 +0200 Message-Id: <20220819153845.581978538@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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,T_SCC_BODY_TEXT_LINE 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 From: Nathan Chancellor [ Upstream commit 78acd4ca433425e6dd4032cfc2156c60e34931f2 ] 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 Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- drivers/usb/cdns3/gadget.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c index c1b39a7acabc..f120da442d43 100644 --- a/drivers/usb/cdns3/gadget.c +++ b/drivers/usb/cdns3/gadget.c @@ -2293,16 +2293,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; -- 2.35.1