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=1796490980; b=yOkA7HKTLJcsniDEgABtu0Q7oy+/hC4bR/Erg1wsXgJQPIhctWhKqevHEpKk0SlNUYCw bnyG0xsl9LYyRCCu1NpoSbHjFaIOyzaJJKm/KFiHplVjCbImsQV6wr7NT06tHvW0kgCYQ J1gjYRcXUnfBvNYRGmsrRDiS8Kmhy8dLiRH++jE/k9yJnQhcG/OobKNrkEJ0U22QZ5JC5 7Q4brn4Vm9pyA7ZdpPrwvrgWZqvD+iZ7P9c4a9ArW/3V7vax3LdCkYLT9wqDNkl1d074e IXxTDFnaYx78pMm/qRiGmVsfe31bNVN+UFq4v6T7l8fZa22FHQ/cRaP8Nn9pYFDOPyA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796490980; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=Uzc0Dz70wLigqjPSnWp9haOmwDk4jnIRdExE1NifKE8=; b=qA8kPUNZq69jZNHcQkoPKplrBkjNywMS7FPrsjMkBklXmZuZSs7JLjV0ZX/lsSN051/a rS8ifVkfxSS4bSIVIlJ/tXBf2I5ZwFHofFlDjEBU3x1H0eilR832jiJ7NjIi9j2lesYwQ nxysQvZXgJsJwMR9v7LIHgSDyURhvygswoA5JqzPXWTItNuhBvy6dwjIPFfqgS4VSUI97 ZHCSoUQjHr67Roa3su1tHcV1LWsnTcO5hX3zfNuqgQz0/UCYstzOWuWItoFFJb+VkMns2 KqzsiVNuJYtdZ503k/aNsIpXoUCvlrMDYuQk4toRFh3kBd1F7zsaIlHvXyZXXZZU9GQ== 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=cgebUqbC; 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 B8E31606A31F for ; Sat, 5 Dec 2026 17:16:20 +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=cgebUqbC Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B73D1F0092B; Sat, 5 Dec 2026 17:16:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796490980; bh=Uzc0Dz70wLigqjPSnWp9haOmwDk4jnIRdExE1NifKE8=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=cgebUqbCBhFKJhBwFlc4e17Jmpglti+cljsV/7TpNyWuQMxFZe5FuPZ1ls2notmRa CYfiQCedTguNsqEGroJTbDzd6fayE4X4bLxAsj9z6WFrsMxYz0MuyaJqFtyoFCNy4b iPSG08PdCkPcLkIcOylA6qQiGmVGgk540t4O/CbGF3n8+RifMFjCdn1acIJLtrXMyl oZ1WlMSj97fAPTxgWf3a0AT+1BfJ0n2vrveI5vpxUnyAFAbsI8RnXNkeiFbZByY1fH DEInUw4YpdWFgr2PaMFtE2p1Myo/Xm0XldUBYgUQ+0Z5V7213a/pdVZcXVhfitYW4W ptB8S07VrEyWw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] USB: serial: cypress_m8: fix write URB double-submission race Reply-To: sashiko-reviews@lists.linux.dev To: "YuanZhe Liu" <25031212351@stu.xidian.edu.cn> Cc: linux-usb@vger.kernel.org In-Reply-To: <20261205170022.4906-1-25031212351@stu.xidian.edu.cn> References: <20261205170022.4906-1-25031212351@stu.xidian.edu.cn> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 17:16:20 +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: - [High] usb: serial: cypress_m8: TX stall and lost cmd_ctrl race in cypress_send() -- commit 5eed4564631ae20c868d4673e55c2a40c9705ee0 Author: YuanZhe Liu <25031212351@stu.xidian.edu.cn> USB: serial: cypress_m8: fix write URB double-submission race This commit sets priv->write_urb_in_use while checking it in cypress_send() instead of waiting until the send label, and clears it again if kfifo_out_locked() finds no data to transmit. > diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress= _m8.c > index bd9b68b691de6..7b6cb9a04e41e 100644 > --- a/drivers/usb/serial/cypress_m8.c > +++ b/drivers/usb/serial/cypress_m8.c > @@ -703,6 +703,7 @@ static void cypress_send(struct usb_serial_port *port) > spin_unlock_irqrestore(&priv->lock, flags); > return; > } > + priv->write_urb_in_use =3D 1; > spin_unlock_irqrestore(&priv->lock, flags); > =20 > /* clear buffer */ > @@ -739,8 +740,12 @@ static void cypress_send(struct usb_serial_port *por= t) > &port->interrupt_out_buffer[offset], > port->interrupt_out_size - offset, > &priv->lock); > - if (count =3D=3D 0) > + if (count =3D=3D 0) { > + spin_lock_irqsave(&priv->lock, flags); > + priv->write_urb_in_use =3D 0; > + spin_unlock_irqrestore(&priv->lock, flags); > return; > + } > =20 > switch (priv->pkt_fmt) { > default: [Severity: High] Does this introduce a lost-wakeup race that leaves TX data stranded in priv->write_fifo? CPU0 CPU1 cypress_write_int_callback() cypress_send() lock(&priv->lock) priv->write_urb_in_use =3D 1 unlock(&priv->lock) ... kfifo_out_locked(...) =3D=3D 0 cypress_write() kfifo_in_locked(...) cypress_send() lock(&priv->lock) write_urb_in_use !=3D 0 <-- returns unlock(&priv->lock) lock(&priv->lock) priv->write_urb_in_use =3D 0 unlock(&priv->lock) return <-- TX data stranded Because priv->lock is dropped before clearing priv->write_urb_in_use, CPU1 assumes an in-flight URB callback will drain the FIFO and returns early. CPU0 then returns without submitting an URB, leaving the queued bytes stranded indefinitely and hanging tcdrain() or port close. The same window between checking priv->cmd_ctrl and clearing priv->write_urb_in_use can also strand a concurrent line-control update (such as from cypress_tiocmset()) with priv->cmd_ctrl left at 1 and no URB in flight. Holding priv->lock continuously across checking priv->write_urb_in_use, checking priv->cmd_ctrl, and draining priv->write_fifo with kfifo_out(), setting priv->write_urb_in_use =3D 1 only when there is work to submit, would avoid both double submission and this stall. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205170022.4906= -1-25031212351@stu.xidian.edu.cn?part=3D1