From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796030404; b=DvWlxqE+e9fUNkaLugwm5iDVleg4FHV9YqWq78rBybRw1/CEnKcpTPaaiUgyGLVZKkwd hLE8tILOtMrKkH7khi9cHkwZGCkl+ptT1FlATU1ei0HLPGLGIQ7VpVNtD5UQ4s7uL9XQQ y3cMUmkChE/dQdtfzR1YNbfnCKfJi193w50L/bsGeJCk7GQxhDY65Dh82xFkO5F6szH/W ABXD9hoD56Tmq3YcGSiSJUeSvZ+fUgYXu8qOdyfC2CQnPfdVyC0auSbjPZY3gsFHlTULG 2cY/+B54yYBnoWj2uJqdkZy9monBq7TlFc+AfR7JmSv7rrtxQqcyBLaR2m953u9Vwig== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796030404; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=aJPc0OGvlJyW4DW/sOrmBSM5lEOCntsDIklmmaksRZ8=; b=SNdor9q5MbixP6+cLeBip6o4dEBzyk/yCaglj6WEQSoNMYgKbNbQMBYKtf2j3cWt+Qp+ RN4mGzeXZ59rtIB5pPYmHByAju0JXzrQ8ugHxVjlm/5r+mbeWC3UrPiUObe/02aOtqQlE J2MWdo+d2eLCBCxy9ClEzZhZatI5RVrFHl+fKRDEPuuJOalqjYkqwLzx+8moB7b893Hj+ LPThVJOWy7hAzx9p6Lhkl+39MWnpnjqUmg8qtBB0AVbRj5+n6nraumAi16Ve8NAhP7oDy Kt0qQBH9vvqCBf021U242UzU7rYtdG082Qj25+n6U0AAMyHAS4xNTPA0efiMJJzNY5A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=at3nBZeW; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD2AC606A31C for ; Mon, 30 Nov 2026 09:20:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=at3nBZeW Received: by smtp.kernel.org (Postfix) with ESMTPSA id 827B01F000C1; Mon, 30 Nov 2026 09:20:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796030404; bh=aJPc0OGvlJyW4DW/sOrmBSM5lEOCntsDIklmmaksRZ8=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=at3nBZeWcaFFB6rFCHbW6n/yajYn8TrWxRggGDmA28ui5So9mossA1Xe57Vd6cxEM Hhf5snq24sRKtEP0mUhf/hEQ14WdwKxuqAlP82EcZWjR+PO1g36OGSOqjowXLHFsO1 PVUwBxSKVn64l/lMEyyCmqg9cea+6Uu53nq6yJBJBGYphKavati0dX8nGBiUZwvQTO 9n3Lb2Gs3XuFazguw0CPvvLW5QMiV0gmUVzGhQJ6mWFJ1tLNc+PML8rz9+7HzS2VMf OAUiQHnNJvemppM8DxRErQ0j8mgOOgpyc3niG3L/lcfc+/UvA8a9pTph9rloxoYuNa p/HYo6BiWqsvg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] USB: serial: f81534: fix write urb reuse while still in flight Reply-To: sashiko-reviews@lists.linux.dev To: "YuanZhe Liu" <25031212351@stu.xidian.edu.cn> Cc: linux-usb@vger.kernel.org In-Reply-To: <20261130090037.24537-1-25031212351@stu.xidian.edu.cn> References: <20261130090037.24537-1-25031212351@stu.xidian.edu.cn> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 09:20:04 +0000 X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] USB: serial: f81534: race on tx_empty in f81534_submit_writer() stalls TX -- commit e5c172675a1d26c17159432b9b68ed3d9a834936 Author: YuanZhe Liu <25031212351@stu.xidian.edu.cn> USB: serial: f81534: fix write urb reuse while still in flight This commit tracks whether the bulk-out write URB is active so that it is only reused after its completion handler runs. > diff --git a/drivers/usb/serial/f81534.c b/drivers/usb/serial/f81534.c > index 8fc60c4d61660..13bd29d5075b5 100644 > --- a/drivers/usb/serial/f81534.c > +++ b/drivers/usb/serial/f81534.c [ ... ] > @@ -517,12 +518,22 @@ static int f81534_submit_writer(struct usb_serial_p= ort *port, gfp_t mem_flags) > if (!test_and_clear_bit(F81534_TX_EMPTY_BIT, &port_priv->tx_empty)) > return 0; > =20 > + /* > + * The TX_EMPTY token only tells that the device drained its > + * transmitter; the urb may still be owned by the HCD. > + */ > + if (test_and_set_bit(0, &port_priv->write_urb_active)) { > + set_bit(F81534_TX_EMPTY_BIT, &port_priv->tx_empty); > + return 0; > + } [Severity: Medium] Can clearing and restoring F81534_TX_EMPTY_BIT around the write_urb_active check race with f81534_write_usb_callback() and stall TX? f81534_submit_writer() drops port->lock before testing tx_empty and write_urb_active. If a caller finds write_urb_active set while the in-flight URB completes on another CPU, both paths can exit without submitting the next transfer: CPU0 CPU1 f81534_submit_writer() test_and_clear_bit(..., &tx_empty) test_and_set_bit(..., &write_urb_active) /* returns 1, already active */ f81534_write_usb_callback() clear_bit(..., &write_urb_active) f81534_submit_writer() test_and_clear_bit(..., &tx_empty) /* sees 0, returns 0 */ set_bit(..., &tx_empty) return 0; <-- data stranded in write_fifo With no URB in flight and no further TX_EMPTY notification coming from the device, queued data remains stuck in port->write_fifo. Conversely, if f81534_write() -> f81534_submit_writer() clears F81534_TX_EMPTY_BIT and is interrupted before test_and_set_bit() by a bulk-in completion receiving F81534_TOKEN_TX_EMPTY, the interrupt handler sets F81534_TX_EMPTY_BIT, claims write_urb_active, and submits the URB. When the interrupted context resumes, it sees write_urb_active set and calls set_bit(F81534_TX_EMPTY_BIT, &port_priv->tx_empty) while the new transfer is active, allowing f81534_write_usb_callback() to submit the following URB before the device transmitter has drained. Checking and updating tx_empty and write_urb_active under port->lock would avoid both races. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130090037.2453= 7-1-25031212351@stu.xidian.edu.cn?part=3D1