From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5CF50331A44; Wed, 8 Apr 2026 18:36:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775673369; cv=none; b=OhnM/v1Ryv7WImpOfcxX8N0J3aWEr3zOWLVF6tZaY8++uQ0jfDHIfiXDCDVmee0DP/M/tyxfzWSYKbRze1RrJkAogquITnGq0B/ymxNRSxzlhFb2ZCZSvlxF1hthO3NMtB0JL0AxQD6SW2bZTVoQDHGxM79qbJT4tXeP+sQF4Pw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775673369; c=relaxed/simple; bh=H7iw1QReXCrqoDkucw6Kfr6sP2IS/oHAT+cTJfLdksQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rbkHj0yrwfmuWl6qu/3rwrVe8ps3SPyCjmgbUTTbdyxq3yXuQ209u41RFCht56P/y4+K2KOp3jviwl5Eh585Lini3cV/e3f2H3Su2He2Zs3V6vL01zkq/KRxBpdWQ2RHqDRy1OmcC7Zz8A0g+DCylHxeQopzKo5P+jNAe90WeEI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=H+KOpFBL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="H+KOpFBL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E73FEC19421; Wed, 8 Apr 2026 18:36:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1775673369; bh=H7iw1QReXCrqoDkucw6Kfr6sP2IS/oHAT+cTJfLdksQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H+KOpFBL9tQYfxXNadCLamzaGfN/y08G4EFNjyyZTHErpwqUBSZjwl7L8c++AKDTW AHNJE17KN1fIZFVBt/apW9eHV4XfcrCx7+K7i5ZAGLRWtYM657l+kgYLOQLuqpPWFY NIh+TAqMLCF6kgew02McrKDz9191TkG5gNIO0a1I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Yongchao Wu , Peter Chen Subject: [PATCH 6.18 205/277] usb: cdns3: gadget: fix NULL pointer dereference in ep_queue Date: Wed, 8 Apr 2026 20:03:10 +0200 Message-ID: <20260408175941.517472690@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408175933.836769063@linuxfoundation.org> References: <20260408175933.836769063@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yongchao Wu commit 7f6f127b9bc34bed35f56faf7ecb1561d6b39000 upstream. When the gadget endpoint is disabled or not yet configured, the ep->desc pointer can be NULL. This leads to a NULL pointer dereference when __cdns3_gadget_ep_queue() is called, causing a kernel crash. Add a check to return -ESHUTDOWN if ep->desc is NULL, which is the standard return code for unconfigured endpoints. This prevents potential crashes when ep_queue is called on endpoints that are not ready. Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver") Cc: stable Signed-off-by: Yongchao Wu Acked-by: Peter Chen Link: https://patch.msgid.link/20260331000407.613298-1-yongchao.wu@autochips.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/cdns3/cdns3-gadget.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/usb/cdns3/cdns3-gadget.c +++ b/drivers/usb/cdns3/cdns3-gadget.c @@ -2589,6 +2589,9 @@ static int __cdns3_gadget_ep_queue(struc struct cdns3_request *priv_req; int ret = 0; + if (!ep->desc) + return -ESHUTDOWN; + request->actual = 0; request->status = -EINPROGRESS; priv_req = to_cdns3_request(request);