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 32F193254A9; Sun, 7 Jun 2026 10:37:37 +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=1780828658; cv=none; b=h5r2tZ5HfaIividZ96+is9XkXq3hnB58Vfaqd/+F4nvxjbQl9h04UmTQFsuU/5rF/41v7OgewrNrGcvLiQABBMrxpiIKT6QRWsoSYSy7intK9EvKsd6Oc2rh373uE1Z+8YctxqeixcQhAVZ8esEbDIduqYIIFDoOpo4FxEQt3Tg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780828658; c=relaxed/simple; bh=JQVDxoETcSP69uYFEJsNfl0LLfGNNxRRLP5zYWzKIUg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XfeDG5jS32tJjCQAIuEmwuWS6fv+FSrNbfFtY6lJPpoGDmdytNc7M/0WQ+ZAhoODLXtv+NE1F0w2M9duvVFBvyWF8nM/9ke8Y96XqJk6bQnFh/HyjtiOjlkhlQbcUAwORa3G6fRzYwDjkWoAI4v7AjhwVI1M9CwQfJq2frRw4j4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=cilEfJmI; 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="cilEfJmI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CD7A1F00898; Sun, 7 Jun 2026 10:37:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780828657; bh=Glem2xpgTe1fnzd2YUMdESNejdz/EGWh3K42K4yj6Sc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cilEfJmIp2tzPI8oyFQicVSMp0VBRw8irowfNNYWktIuqUHIEcCFf/RhXcymjnT4O +KLBJa/7JLaeWyCeZ47hpUOY87//WYzhl5pe4SVsrycWR8V4GhNRgM3odORjZRrVRz 7tzNb0vfU+Ky7CIOVavRuGg5itjjXJ0LJUppEFLw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Dan Carpenter Subject: [PATCH 6.18 180/315] usb: dwc2: Fix use after free in debug code Date: Sun, 7 Jun 2026 11:59:27 +0200 Message-ID: <20260607095734.191464037@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260607095727.528828913@linuxfoundation.org> References: <20260607095727.528828913@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.18-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);