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 068DC47044A; Mon, 31 Aug 2026 13:49:02 +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=1788184143; cv=none; b=aPzFh9G9K45fEQgHR8twiC9Mue/HyNTExJA03Ld952Z4Dn5L6cps54Abn2k37kvBOK93Iqu7oXsg+zWUE8dZNlwFrvRhlAvoWQce/GA57fqY033Enr2S8P8AuiSZBt8iW/TQIF5AuCxujkFlaH95Hn11bam95qKI0vkaTMsCh9s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788184143; c=relaxed/simple; bh=HKjGyrxA7qFpj5sBJvoM5ANi9yQUXuVwVPluKt06Ziw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MaKp0dSo9iIaRi/0AzwLyS6TtY0K9IdtnvvyE/B2bQq/20yq3/gv/gQvw0FWrubbomIObZLyH2YjubOCcnxe8rMsvPnyEF43mhojVx+v+s5RVNOQiVRdIoAQhVmbdaZ1vCPtdLHIi1FAg/fVR8BZVxo9j+PUKYR5y0WJKEVb/iA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=LMY5ng40; 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="LMY5ng40" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 634271F00ACA; Mon, 31 Aug 2026 13:49:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1788184141; bh=YPSN9LDaFnxT6wF+VXfpWdZ2Dhi1tM/3aLM6qNpJDOA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LMY5ng40cVIb00SDZeECYOKdD2ehu1a9a/AbGuP68NXC1dYyz5+ShKniuimr7tpSS HrWmtJqHqTNkPWbJt+J5+mW9X/FuQGP0hTDaaaIlq6PHZoALgJiAJWRrDuBA0MSDU0 fd57Fta3KGDu9u1HarthGn84m/QpB3J2meZvATSM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Shuangpeng Bai Subject: [PATCH 6.18 81/83] USB: c67x00: fix use-after-free in c67x00_add_iso_urb() Date: Mon, 31 Aug 2026 15:34:57 +0200 Message-ID: <20260831133403.529639722@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260831133359.207714926@linuxfoundation.org> References: <20260831133359.207714926@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: Shuangpeng Bai commit b1e24de475bf2d66fffc9103f3444b783527d55a upstream. When TD creation fails for the last packet of an isochronous URB, c67x00_add_iso_urb() gives the URB back before updating the endpoint scheduling state. c67x00_giveback_urb() frees the URB private data, and the completion callback may release the final URB reference. The following accesses to urbp->ep_data, urb->interval, and urbp->cnt can therefore use freed memory. Update next_frame and cnt before giving back the failed final packet, making the giveback the last operation that uses the URB and its private data. Fixes: e9b29ffc519b ("USB: add Cypress c67x00 OTG controller HCD driver") Cc: stable@vger.kernel.org Signed-off-by: Shuangpeng Bai Link: https://patch.msgid.link/20260806013502.322067-1-shuangpeng.kernel@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/c67x00/c67x00-sched.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/usb/c67x00/c67x00-sched.c +++ b/drivers/usb/c67x00/c67x00-sched.c @@ -761,13 +761,13 @@ static int c67x00_add_iso_urb(struct c67 ret); urb->iso_frame_desc[urbp->cnt].actual_length = 0; urb->iso_frame_desc[urbp->cnt].status = ret; - if (urbp->cnt + 1 == urb->number_of_packets) - c67x00_giveback_urb(c67x00, urb, 0); } urbp->ep_data->next_frame = frame_add(urbp->ep_data->next_frame, urb->interval); urbp->cnt++; + if (ret && urbp->cnt == urb->number_of_packets) + c67x00_giveback_urb(c67x00, urb, 0); } return 0; }