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 1AAEE43B6C1; Mon, 31 Aug 2026 14:02:25 +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=1788184946; cv=none; b=bV/wiTYPMKh2xFOuA/PmkZD0mzjBHxOVOOUgVUjXPcXwPTcurllWmpjEOCj/KE1sOtxpj3xDxjjeT+hX4R05Bon2MxJGU7H/5lyonRPnV/xEbxyV61R+MCjXLkDYl9UhJFNExNXKktRWACMFgeeSK4dnB06H4w45cCYnmZvlaYk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788184946; c=relaxed/simple; bh=eDfzta0REasG3u1wHlTop6HHeP0bK9CdK2fP2B7DnKw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T7V2/MtdCM9wfqFj0bGNHq/BDacIQ9DYvZEmrFIykRyCAfc5Z362ESduAXdzV5tYx6IGUlf6wHBbC1kCoi5XraZo4OxoZLozPpOLEfc9TfFLYD1wtQBPq8siwRbRdmpddu6wpM2g65d4xFT1k3GO/Nh6623Oh8OejnfVFyftp0U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=WcfgmN1K; 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="WcfgmN1K" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 767C21F000E9; Mon, 31 Aug 2026 14:02:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1788184945; bh=rzeAkHMv7Bd0tCcpVS9iTWxBa/U7ngNqGeZ2SgZF6G4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WcfgmN1KHd/TGl0tgYArTt0W2DsyWPb2gRP/mOuTMuDCu9L5oapLYya/zIyNTg23+ cd9grPvNflXAQ6YF2Jvupr5k611tan8D8rKHmRxmjpAyneCEEsWmpnqbcQXBMUb6rE NP0Cg5nWVF0xOjrgIElSnYmTi15Fhvf0Bp16Vepo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Shuangpeng Bai Subject: [PATCH 6.1 91/92] USB: c67x00: fix use-after-free in c67x00_add_iso_urb() Date: Mon, 31 Aug 2026 15:35:29 +0200 Message-ID: <20260831133404.117643843@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260831133359.482388899@linuxfoundation.org> References: <20260831133359.482388899@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.1-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; }