From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94BAA355F49 for ; Thu, 6 Aug 2026 01:35:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785980122; cv=none; b=gkVBjySWnUvQpqFraqiUVNo8K1GMHi/ozDsT2f4g8zsR0nYoDgX+zNtT4o90FYY2K+caBv1OFVdFJP4LtUyxIBdUu9WUOhs6PsrODVy573oCFjy4hSVIYR2S4wEnNAjf+1/EEy3hqMY54CPQTacdvLx/YDh34242VvgDn2kZjZg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785980122; c=relaxed/simple; bh=nwn2lZ3SCz5qyQG6mlgmrXj0cWktoRX0y3iA14280Aw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=hTYbWZLa+uS2hg3esCqQiB3IgTBahhdRKN385bYq/TsflNV6TCNG4RqPVg+DfOxDBLmDL+Hmea5cWS6eKzzs4jMRy+K0WmJImmvs5+MKZ7cJQuFtgN6Uz2bIMATYqbFq8tgPLVi81d/oesQjJZC9DbmuXTmL+qiruTph+EcA9bA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lPCk4/oz; arc=none smtp.client-ip=209.85.222.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lPCk4/oz" Received: by mail-qk1-f175.google.com with SMTP id af79cd13be357-92e5b048375so90029285a.1 for ; Wed, 05 Aug 2026 18:35:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785980119; x=1786584919; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=L68zcBOEKqyAHNXodlM2tK6G5hxNC0P7ha7It9IyfZQ=; b=lPCk4/ozgel0NgLcQzErGQYvIEmpcPQyAPYszHioXVnoKawBltEuxH0dWV7V/X1Y5i XPbYipevNDTcLeAklMkcQe9uXJCG+1JAmdhD6nXMuNpwfj330zLchmQ86jdydWMHp1hV z2J3cjrdPfigN4yZVeInWfyAgC+B+OTm5D2imsZ5sjiRblFEbJCEnLp0Yhdd//HXdO1w J9obau6Mj7UmD/dbCmfkEvjnHQOwKeXEhRYIqApU9S0vqHa3fA+/j44QSi4Z4p1Fqhqt qAGYLxEHM6kozZXsXAGJ99MdjHHoqCqrzMsEE04Fn3W5xZn6p6jZV1RL5B156ovHGSCD C46g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785980119; x=1786584919; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=L68zcBOEKqyAHNXodlM2tK6G5hxNC0P7ha7It9IyfZQ=; b=PdbE+392GLt6dOplA7RwHbCjmm1m7iXJDCS8XmVpDIqKttLi5i6sKq+2t0Z3dxx5e9 7pt3vNpQGUxQDnoMyDlyZNGUG/z6UdZ3V+snvIcFWeB1xv3GINE3dKPtK5HZCg8a8Rc6 WGRinQWuHbR4SsGYsFdHX+6p2/WKAMitn1+a458nIRP8ygXPQKxCfE93SPymSprwiXIw 0J9XPNCgqNHkoIFmMu6UCr1YAlV97lNLgSkkYFXwNwHfqOO5F6qua+CmEC2peQecN5LS epekDnpjpxm1/aU/CCRuxk8SB2qOZvvCLEY9mPLdyV7bYQ0yurpsA3CsaAEhMkGr39gV ZHGw== X-Forwarded-Encrypted: i=1; AHgh+Ro5H3mv0MJ0Z1Lg/3TAiZBW5rbcp79ZOgg3+t4wvSg+Dx0UfWLs0CenKSvfdkKNYRNFZOEBv7xqHw/G4dw=@vger.kernel.org X-Gm-Message-State: AOJu0YyEkLhS/ExvpDgTPLlZrw9pNZD+p9QPHfUd1HmMZHNrflVLwbos QYOxv8qtMxUyvhLYzK7T6L7xDHTXdkU2L9bEEYlvjzSCTGCESWcYZWaEI85IoKTj X-Gm-Gg: AR+sD11uVpZSbHC4GCjwASJeujy1Axbrhbnj7x8gwr25N9bmkYlK5hKSXXk17oKtVbJ rSXVSyVyiYB6o8nHIAp2d7Vs3WbTFc52xuE19W86jzVI3f75X3tqaDg9ek8q6nW3Z4sfdA/RoCd Vm1wz1v2HZIFFcFgkFW8Ppn7c31XgJbQ8NWTBWizkfmDjxahK2SstdnPgb5gAZV+8WjBP9EX0zU Zvl6GUtWQ8FZC0tn8oFohyEt1Ha/fiHvRv1NNLqBQB39NI+JXnk4VXS48BCC6Lm7Q/WedYjnWgV jZovqUaHTh2gbX64GlI5Wp2z7Py8paVFHKfxlZEm1VkRJEnBIKPsaw3Oh/BJOWlFSQ8Z93/EIZL lxf1L0qmrb/reE5ZOs8cS+zCYc5q20+dzgGTbnkBuyXhNGGtIMXGuFylfyH5K44dXTMqjuAyYzY y9bNhTnlmKT74lJogIAw/DiTfW9lVsPO+nUUvh7VwcXiBjCNpjHesARK+PX96i/5O9z5wOeTs2e bJ9+NINhVM0rSuxPWkaA7oFu9UV X-Received: by 2002:a05:6214:1bc6:b0:8f0:3b2c:a9c8 with SMTP id 6a1803df08f44-908811d8ddcmr133559146d6.12.1785980119508; Wed, 05 Aug 2026 18:35:19 -0700 (PDT) Received: from i4-l-hqh5357-03.ad.psu.edu ([130.203.139.71]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-908800add3dsm39453756d6.39.2026.08.05.18.35.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 18:35:19 -0700 (PDT) From: Shuangpeng Bai To: gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, jacmet@sunsite.dk, Shuangpeng Bai , stable@vger.kernel.org Subject: [PATCH] USB: c67x00: fix use-after-free in c67x00_add_iso_urb() Date: Wed, 5 Aug 2026 21:35:02 -0400 Message-ID: <20260806013502.322067-1-shuangpeng.kernel@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- drivers/usb/c67x00/c67x00-sched.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/c67x00/c67x00-sched.c b/drivers/usb/c67x00/c67x00-sched.c index a832f5696f2a..ae6c94f41cb3 100644 --- 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 c67x00_hcd *c67x00, struct urb *urb) 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; } -- 2.43.0