From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 B6A372C1595; Sun, 7 Jun 2026 10:42:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780828944; cv=none; b=C2x/yX3LSEYcgFWOSrg5+c/a9sGx52KhcP8+0ds0asyv2E0+QbWi+HXwWcEIlobHqDPq4bX9r2uHHENlvtxS1sib9qUUXTN9ZPP/tu5QnnF+iWopzhE/GG9wKWnSVLwuQL51Vx9DTxrxcjgovDUl+JMrGEk7GVC5lEXTcLCWaSQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780828944; c=relaxed/simple; bh=pnFqJCok0laRNvp32fN1epAjiMMUDebBZQpCH01UTHw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tnrFYkOAo6Z+Hz21c0OeR1z+P9YkxXLrOjnenSLgIoz4kDgtqM66z0ZnmHzbh/5VBA0SVTPmdmIgKSWaTV44i9jQZHZEeDPEnNLw8r+LVSMZe9MR/ofOrOF1pflHNFuEd/xObrSlzvJBCeLFnFo1kULr9NvFp3zVRgjqn6mMxiM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=c8pyoxyV; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="c8pyoxyV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDA201F00893; Sun, 7 Jun 2026 10:42:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780828943; bh=Zydrbej5QSpZoMejegKVsD7v6wmv8udVqSYQPmAzW+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=c8pyoxyVAHzBPLxZ8sjfS+Kx/E7r5c1BMQwNKiEeDsLRGvGvaRnywtn1n6aQ5ZZw6 4PcnrB/tc55CORPYIRemJ7WUuTApuLWDGsda0SaOY6Yqo2So/icCW/6nj5gxx1jmsj Af2hS5r5EfCZnH1KlslPujVkEMtZvyrn4POGGOiQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Dan Carpenter Subject: [PATCH 6.12 181/307] usb: dwc2: Fix use after free in debug code Date: Sun, 7 Jun 2026 11:59:38 +0200 Message-ID: <20260607095734.361192383@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260607095727.647295505@linuxfoundation.org> References: <20260607095727.647295505@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Carpenter commit 9ea06a3fbf9f16e0d98c52cb3b99642be15ec281 upstream. We're not allowed to dereference "urb" after calling usb_hcd_giveback_urb() so save the urb->status ahead of time. Fixes: 7359d482eb4d ("staging: HCD files for the DWC2 driver") Cc: stable Signed-off-by: Dan Carpenter Link: https://patch.msgid.link/ag1NwBpqT4IEQcdJ@stanley.mountain Signed-off-by: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc2/hcd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -4804,6 +4804,7 @@ static int _dwc2_hcd_urb_dequeue(struct struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); int rc; unsigned long flags; + int urb_status; dev_dbg(hsotg->dev, "DWC OTG HCD URB Dequeue\n"); dwc2_dump_urb_info(hcd, urb, "urb_dequeue"); @@ -4828,11 +4829,12 @@ static int _dwc2_hcd_urb_dequeue(struct /* Higher layer software sets URB status */ spin_unlock(&hsotg->lock); + urb_status = urb->status; usb_hcd_giveback_urb(hcd, urb, status); spin_lock(&hsotg->lock); dev_dbg(hsotg->dev, "Called usb_hcd_giveback_urb()\n"); - dev_dbg(hsotg->dev, " urb->status = %d\n", urb->status); + dev_dbg(hsotg->dev, " urb->status = %d\n", urb_status); out: spin_unlock_irqrestore(&hsotg->lock, flags);