Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp834255ybl; Wed, 11 Dec 2019 08:12:03 -0800 (PST) X-Google-Smtp-Source: APXvYqyrL8lU0MV4ymVLfzy5plIlREgqfISNJppp9RPP2X64Dj8LfdpZKhO9+rEirATjUxlQOpOY X-Received: by 2002:a9d:6395:: with SMTP id w21mr2890176otk.3.1576080722912; Wed, 11 Dec 2019 08:12:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576080722; cv=none; d=google.com; s=arc-20160816; b=cD8GHzdANQMtJ3ybvbrpanLnKKFyzmx8aFcBS0xL/AdzCGscxDdCRY5QSbNKOM1myF CppWndNDUJlly23ss+NXDXzd5c855JFm4pJMuwG4Qk+yIAtwpy/UzkLNXxn09w9X0qPB rAi3bPGR5HEqsD3cpsGVwUdRC8v1GrBn9rz9oXfiDq9PgSNDkh2kfY7ZkSiXtNb+OotN LcMP0yhhJC8lAxis5PlmH73hWHr4NHtiz4WVih6FUIhKlZ03pSIW9+gcU64U12Qz2LYp VyDNBYj4cN9pNp5pX1sAsb3/sHQQbQcdOCErRaY5wakjzrFw96NyKn2RARd84x18ZgnU 28Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=prAV11FKQkb6imRCYLNf1cl3omHSPcTVaH8MKHiWoes=; b=aohgEMMvcI9QZU6W2PzzVHp9S4on+BbqpeTm8J7C2i5zloGQEzu+51YOHsbTwm+OSb aB8l9tLVfTM5HhRIpDAmduqHyHjcHf7xvz54N0m9mSJr99jTlq1Cgq51vBRSZUeAKoN+ 76naMZ/wQDKJd6pz3Zm0nCv3TDXaEKtR+9YMQHKXS8vb+1U0vB8D4Wma+SSd71NNhu28 KFgtQh2dHKU06QCCAZrhEOSiq4SJwCiL/JmoF3vTCWFXLukSQnbJWU1+me6YVljouhQY 4rUkPomkF9LgHS+Z1DzIOyVuwwA/0fOZGGNi3N/D3QThSmorAYGjcd7NdtCqnnu+qz8j t3RA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=L8a2aq80; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m1si1278202otf.174.2019.12.11.08.11.50; Wed, 11 Dec 2019 08:12:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=L8a2aq80; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730418AbfLKPLj (ORCPT + 99 others); Wed, 11 Dec 2019 10:11:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:60226 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730284AbfLKPLf (ORCPT ); Wed, 11 Dec 2019 10:11:35 -0500 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 745DF222C4; Wed, 11 Dec 2019 15:11:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576077094; bh=S1YkN6O6yv6W4P5KTj8GXvZtQ4bxmpqDV3ZgFsMXh38=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L8a2aq80O3F1muP6A0t+Ki392YqLk2r245fyUz+aUJP1bePRFGJnhk820rre3Sd6J dnjFyVUKYOXzPR++JyKvIRC3RPzzwhyTsiLwsP4jG1EaT+t8fwkCHRyP7aMpJg8ka8 yVbAEf+fp5Y4iF/mAckso5O3aE13IMPa7RXEPXiA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Ladislav Michl , Felipe Balbi Subject: [PATCH 5.3 007/105] usb: gadget: u_serial: add missing port entry locking Date: Wed, 11 Dec 2019 16:04:56 +0100 Message-Id: <20191211150223.060339802@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191211150221.153659747@linuxfoundation.org> References: <20191211150221.153659747@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: Michał Mirosław commit daf82bd24e308c5a83758047aff1bd81edda4f11 upstream. 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 Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/u_serial.c | 2 ++ 1 file changed, 2 insertions(+) --- 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 *li __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; }