From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE255C18E5B for ; Tue, 10 Mar 2020 12:56:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A5B772468D for ; Tue, 10 Mar 2020 12:56:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583844981; bh=FvBTo3UkqZq2iW0czPeO5xCooCJoFfWcEZh66gx8an4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=uE6tpMSjtA6aArKRf/JjSxL0YgdktXWuNohV6c3eJoOppBxZHfKQMaugv2GYM9zVR 0c7TRDeJUICRgq1nuPDf1PXVhuF/QL0/iDWHD/mK3xzJCQvskLJgHtYB16JQViZt3u 7FVUS5xmlqB9S4/dx2+WyPx9PFVfboY/vcDWzIDw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729643AbgCJM4U (ORCPT ); Tue, 10 Mar 2020 08:56:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:35416 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728475AbgCJM4O (ORCPT ); Tue, 10 Mar 2020 08:56:14 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7D4632467D; Tue, 10 Mar 2020 12:56:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583844973; bh=FvBTo3UkqZq2iW0czPeO5xCooCJoFfWcEZh66gx8an4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ReOQQCITh/KjDDhiDLzW7xheO7hZ9VMd2TzVuTdFtN9TBeMAHmppq4+8+Y0GLY4Ut 4pL49eAyqixJ2k0svGg0oBIQEjYnzAyrNEXoHVvaXyUpa7+Z2li1zx8r4+8qXntx7v 3/6jPa0kwSYTzNcoraMoh2CC37AiN/9z+fxaESqo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sergey Organov , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Felipe Balbi , Sasha Levin Subject: [PATCH 5.5 018/189] usb: gadget: serial: fix Tx stall after buffer overflow Date: Tue, 10 Mar 2020 13:37:35 +0100 Message-Id: <20200310123641.330917540@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200310123639.608886314@linuxfoundation.org> References: <20200310123639.608886314@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sergey Organov [ Upstream commit e4bfded56cf39b8d02733c1e6ef546b97961e18a ] Symptom: application opens /dev/ttyGS0 and starts sending (writing) to it while either USB cable is not connected, or nobody listens on the other side of the cable. If driver circular buffer overflows before connection is established, no data will be written to the USB layer until/unless /dev/ttyGS0 is closed and re-opened again by the application (the latter besides having no means of being notified about the event of establishing of the connection.) Fix: on open and/or connect, kick Tx to flush circular buffer data to USB layer. Signed-off-by: Sergey Organov Reviewed-by: Michał Mirosław Signed-off-by: Felipe Balbi Signed-off-by: Sasha Levin --- drivers/usb/gadget/function/u_serial.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c index f986e5c559748..8167d379e115b 100644 --- a/drivers/usb/gadget/function/u_serial.c +++ b/drivers/usb/gadget/function/u_serial.c @@ -561,8 +561,10 @@ static int gs_start_io(struct gs_port *port) port->n_read = 0; started = gs_start_rx(port); - /* unblock any pending writes into our circular buffer */ if (started) { + gs_start_tx(port); + /* Unblock any pending writes into our circular buffer, in case + * we didn't in gs_start_tx() */ tty_wakeup(port->port.tty); } else { gs_free_requests(ep, head, &port->read_allocated); -- 2.20.1