Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp584471imn; Thu, 28 Jul 2022 09:36:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uteImTk4unMDKHJDB1Tu/WJ+ItY59kjMLI0SiD6SqJODrV093kdr51lkYbYEi4bqAZyrA+ X-Received: by 2002:a17:906:6a0f:b0:72b:64ce:289d with SMTP id qw15-20020a1709066a0f00b0072b64ce289dmr20879214ejc.663.1659026175090; Thu, 28 Jul 2022 09:36:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659026175; cv=none; d=google.com; s=arc-20160816; b=q+sCA91zCI/U//pNWt3KTbG1yYoiSTayDllPbMKf8muzk0loP7oVfAMP5bkFi7Vj7K Apy0YMoqdyUztn3DrCBJgeNw53xIVQ+lLQ7BdgHgJNV3Xe++K628y7NctcD9XK/suo3t /B6PKiBRsBFSMxKS0WQNX9FMiZAeZx0bWHp/dE9J7C2RzAk9PVn8zbYNW25ESZh4XoB9 YEC7347dNZ4YPoa3M4dmaALWcVRQ79RZke/ZkQSg2bbO130AYY/pMRxpjoCtiyYklRmG whN1NasxwuJg1v2ss4rhGOl7oGgV/TV6EVqtUR1S1FUtYtx68Bg1CW9UiAS23Q7h9HcU dsTw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=TrxQ5TibiClYi3kxkvshwPEAejCgU+U8fSAhVx8n3kI=; b=xhV8PfwusyqhUOAL4smdTV1dnQCMffTvGJatgRySdf5ZB5SX1RfzqA4rS/PnNZh425 Gz1Ap/iOg0sPemBHvfODaqdBMdAmWkX/GBJAPvim4TOD0Cwl9VGhkbA0E0sond20aCZ/ CRIZZW48eIU2Wrjg38UkWvgDVcycu5KgVpVFO/V3b2EzkNogauW5z4NULWokr/Dp49bh ueGyBp3QQicF6sugs2bc0RAkZdqVyLQBEKgVVX+aD2m0DHXD4zXAa90uC3IDzD3AnSXx nAY9l8v0OmH1gTAQotAv3ITzPqVX0YIVF0NPDSAp4Cj5QsQplo9SWPc6dnlB5CRuumVq Smsg== ARC-Authentication-Results: i=1; mx.google.com; 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=NONE dis=NONE) header.from=ispras.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gs33-20020a1709072d2100b0072f1b3ebaafsi1123584ejc.136.2022.07.28.09.35.49; Thu, 28 Jul 2022 09:36:15 -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; 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=NONE dis=NONE) header.from=ispras.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231844AbiG1Qap (ORCPT + 99 others); Thu, 28 Jul 2022 12:30:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232295AbiG1Qaj (ORCPT ); Thu, 28 Jul 2022 12:30:39 -0400 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FA0CFF9; Thu, 28 Jul 2022 09:30:27 -0700 (PDT) Received: from localhost.localdomain (unknown [83.149.199.65]) by mail.ispras.ru (Postfix) with ESMTPS id E3E7040737CF; Thu, 28 Jul 2022 16:30:25 +0000 (UTC) From: Andrey Strachuk To: Peter Chen Cc: Andrey Strachuk , Greg Kroah-Hartman , Pawel Laszczak , Roger Quadros , Aswath Govindraju , Felipe Balbi , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: [PATCH v2] usb: cdns3: change place of NULL check in cdns3_gadget_ep_enable() Date: Thu, 28 Jul 2022 19:30:14 +0300 Message-Id: <20220728163014.247082-1-strochuk@ispras.ru> X-Mailer: git-send-email 2.25.1 In-Reply-To: <16589929667170@kroah.com> References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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 If 'ep' is NULL, result of ep_to_cdns3_ep(ep) is invalid and priv_ep->cdns3_dev causes panic. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Andrey Strachuk Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver") --- drivers/usb/cdns3/cdns3-gadget.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c index 5c15c48952a6..51de7457a3b8 100644 --- a/drivers/usb/cdns3/cdns3-gadget.c +++ b/drivers/usb/cdns3/cdns3-gadget.c @@ -2284,11 +2284,14 @@ static int cdns3_gadget_ep_enable(struct usb_ep *ep, int ret = 0; int val; + if (!ep) + 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; } -- 2.25.1