From patchwork Wed Feb 27 10:46:57 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: 10831535 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 36596180E for ; Wed, 27 Feb 2019 10:47:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22F992C6EE for ; Wed, 27 Feb 2019 10:47:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 170572C70F; Wed, 27 Feb 2019 10:47: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 C12CA2C73A for ; Wed, 27 Feb 2019 10:47:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726931AbfB0Kq7 (ORCPT ); Wed, 27 Feb 2019 05:46:59 -0500 Received: from rere.qmqm.pl ([91.227.64.183]:31949 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726397AbfB0Kq7 (ORCPT ); Wed, 27 Feb 2019 05:46:59 -0500 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 448XQY3zQJzJX; Wed, 27 Feb 2019 11:45:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1551264341; bh=q3dmSavRAaTLVOyB3bYchJD0/kxWEL01eNi0BB2jO7w=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=XnQ1G7CsjVGjdVp7vv3njLtV6+N2gRsctLyUVyacm+uYxxD54IcYlRSUtnlqr0pK/ qx2Xzoakz541MIHhv2+ML3uu9RFpOcdcN8XV8xZic1thIxJuAaTsvEzDzflfYSiYyO FRHg3PHQ+0Yr/rqshyEdntdARksLYoQsZ4xcFHjQAZxRPdLwf0hCLX/iNdp7tNlLeJ PxuYfqRvX3tUewXMSRJ2/LDflKR+e1x0ZOTFEjzTqXGq+dtn4ynrYjWuEMwvAZRiw6 vRkhkNlY949bBmZsA9fJCgsBCmssVjtcZ4KJuVDe/h2+zeSDX87SF5Kldpjfv2Yc9M CPadvo/rMm1UQ== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.100.2 at mail Date: Wed, 27 Feb 2019 11:46:57 +0100 Message-Id: <7e94cf9d80899fe76537b455bb5668cc7ed0fa08.1551264094.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v3 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. Cc: stable@vger.kernel.org Signed-off-by: Michał Mirosław Reviewed-by: Greg Kroah-Hartman --- v3: added 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; }