From patchwork Wed Feb 27 09:29:37 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: 10831463 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 05F1117E9 for ; Wed, 27 Feb 2019 09:29:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5BF32C502 for ; Wed, 27 Feb 2019 09:29:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DA8D12C7D5; Wed, 27 Feb 2019 09:29:40 +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 8A10F2C502 for ; Wed, 27 Feb 2019 09:29:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728632AbfB0J3k (ORCPT ); Wed, 27 Feb 2019 04:29:40 -0500 Received: from rere.qmqm.pl ([91.227.64.183]:64755 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726194AbfB0J3j (ORCPT ); Wed, 27 Feb 2019 04:29:39 -0500 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 448VjK451LzJX; Wed, 27 Feb 2019 10:28:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1551259701; bh=6LhUc6bx8F5ho/WTezNo03Atn7tHAvVp+4quXdtJdco=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=Bqqt5gmh3oVoFuyZwPIXHj34tzgAqyijw1r2Z/gWj4DHWKm0lW6LR2ZboxgqtHvAw eqQwtzLJIjr/f2ZECh8a/JN/80Q2Rm3YbxKlUkC3CxNd3RWyvR8HUVkXzfDUGu0oET jE2B9hCVzwGQkqPBIQxx1VdJfRQaHrfdtBlArV/QpQ0BaNFJdIt0ZGJaMNrp57vcA1 y6paRTSA3ynFX+MnVO/04sMhNVnTDNMg9JxzIa1izqMfR+Quo6PymBUuVaKm8o7fa0 sfzZGcj602qWlRMzdjV+HHIegVnRMRwoWz6KfVVUsAaNpG6j1vxiRaBCw0DqiZIppu 1vZ23GlMfoGnw== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.100.2 at mail Date: Wed, 27 Feb 2019 10:29:37 +0100 Message-Id: <5365749544fb509adeaca88754726eb14070b7b4.1551259482.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v2 1/5] 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 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. Signed-off-by: Michał Mirosław --- 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; }