From patchwork Wed Feb 27 07:48:56 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: 10831365 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 E08901669 for ; Wed, 27 Feb 2019 07:49:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFC2A29B9A for ; Wed, 27 Feb 2019 07:49:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C43882B5E8; Wed, 27 Feb 2019 07:49:01 +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 EB03C2A356 for ; Wed, 27 Feb 2019 07:48:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729582AbfB0Hs7 (ORCPT ); Wed, 27 Feb 2019 02:48:59 -0500 Received: from rere.qmqm.pl ([91.227.64.183]:21003 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726702AbfB0Hs6 (ORCPT ); Wed, 27 Feb 2019 02:48:58 -0500 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 448ST86bWbzJX; Wed, 27 Feb 2019 08:47:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1551253661; bh=9RtTC/x97iJT7E9jhPBjHjTZM3xVnkiFvfHbp5E2RUc=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=F6rA0vY+tBvqABiFPYR8+k39OPzYx6SCbJRmVoq4qbRjhWzanj9JXK5a5fEx1BG33 HYR8K8zSsF3DZ4Z0GdSYu04HAuAMjXIeIJ9bmdtMMTcTQTuDCcLzNqFpZwweuOQYye odDyk299n3cF70TaqednQklF7cEHcGYImB3yRY5/pHSSef23qjmMa12cvzeeYThHtr w7uk1jQWwdTlwhNKF+bO1YC3hs929fqjTDHbmFlol6+btMLhy50C7d0QFOmHrtBJy0 pD3GWWuVzEWyD68K5QhuCE9Z/gPo3IYdwkV7bMgDtQ8+JLTxKryNr5JYhvstbNkVYp UNas35evClI5w== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.100.2 at mail Date: Wed, 27 Feb 2019 08:48:56 +0100 Message-Id: <1437fea1a8e1ca2c00870451197611df29c1a7ac.1551253561.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH 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 --- 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; }