From patchwork Sat Aug 10 08:42:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 11088449 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F285A14F7 for ; Sat, 10 Aug 2019 08:43:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3351212E8 for ; Sat, 10 Aug 2019 08:43:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D626A2267B; Sat, 10 Aug 2019 08:43:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80ABC212E8 for ; Sat, 10 Aug 2019 08:43:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726132AbfHJImv (ORCPT ); Sat, 10 Aug 2019 04:42:51 -0400 Received: from rere.qmqm.pl ([91.227.64.183]:53501 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725863AbfHJImv (ORCPT ); Sat, 10 Aug 2019 04:42:51 -0400 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 465FvN2HhjzDq; Sat, 10 Aug 2019 10:41:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1565426480; bh=e9HoIno2Ud8Ms+1jHlklnu2iR2HfeMr8Q+Yz4Y7K1kM=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=ViEkGJ482Yw0Dx8ReA6sAcOxN52Kza1DGpdfAgdNdARVhRE0pxdTBqoZbyh/kPnHO VF6CRYyJ9vqY9cciElWbv517N1cJ9WRxetPAwg3qe4bS04hAVZLajOOHeKfP2kZDe1 +C8KpofGgMKVqlzP4Hmo5Re/b2ZNXJ8yzrT2RpKydL7KmsVy7fB/cs3W+FakrdMN91 s+h510653B+F1qaChrlytnZCliUb/DCLrb5jThvSsZXYsMhi5tbp/dFsNW1MkI1tIr OW8HjHLKflhvu0uZCW/kHC/nLUaGgkmFTfgrYtMv5mtllKX7nw6A3G+WbFuuOtmTnE 1iSR0NDNRe6cA== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.100.3 at mail Date: Sat, 10 Aug 2019 10:42:48 +0200 Message-Id: <4f3ba23fd4e8963cf5651290a34be894aeedb570.1565426370.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v6 1/7] usb: gadget: u_serial: add missing port entry locking MIME-Version: 1.0 To: linux-usb@vger.kernel.org Cc: Felipe Balbi , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP gserial_alloc_line() misses locking (for a release barrier) while resetting port entry on TTY allocation failure. Fix this. Cc: stable@vger.kernel.org Signed-off-by: Michał Mirosław Reviewed-by: Greg Kroah-Hartman Tested-by: Ladislav Michl --- v6: rebased on balbi/testing/next v5: no changes v4: no changes v3: cc-stable v2: no changes --- drivers/usb/gadget/function/u_serial.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c index 65f634ec7fc2..bb1e2e1d0076 100644 --- a/drivers/usb/gadget/function/u_serial.c +++ b/drivers/usb/gadget/function/u_serial.c @@ -1239,8 +1239,10 @@ int gserial_alloc_line(unsigned char *line_num) __func__, port_num, PTR_ERR(tty_dev)); ret = PTR_ERR(tty_dev); + mutex_lock(&ports[port_num].lock); port = ports[port_num].port; ports[port_num].port = NULL; + mutex_unlock(&ports[port_num].lock); gserial_free_port(port); goto err; }