Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1340752ybp; Thu, 17 Oct 2019 11:18:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqxKOqcKNJ5JIP93/UC8Kn4vkuTfjCihRNjaRxQmmFFUhEDuzvmmotkFa938aClxhVKGL6eo X-Received: by 2002:a17:906:31d4:: with SMTP id f20mr4810298ejf.265.1571336307712; Thu, 17 Oct 2019 11:18:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571336307; cv=none; d=google.com; s=arc-20160816; b=QdTU8XTiSLRGaDj6tYyMsE1D8odmGgMqUJ67g0qqR8hoXyKWMgD0juW2XGM8a28KDI UyT2JZRD1FSfLAdn3/cF79hElRMAEkH29MCMYeWYDMAEGbm9oPkp3pnDuRhYjsfFkyNR ciDbceb1dffhRtIJEp8UQsWj17bAYwXtPZDVo8V4YmTq2NxA+D3fgqHcELL7Z5PsHcj2 cei6MqBiIJCi9ghoogR9KFPc8WamydNOUFu0AYDaYefQ+rf64vX+WynQyZywXaJnIvzg rD0GnIyrWh8cRP2Nor4xPikz3km0ybKHEaE7VWJ88pMNuOm22rvlDHpD1ffxVIts2iAY fwrQ== 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=lUxgCar1goH8fx/UWR2I2k+rAfZh1jR6FskpMbdwiHQ=; b=xXmptuuLR/XC56fWxOVkEQoJeaVi8T+NWCs033tpbGk4k5p/Gpf6Nf/93Y7k1AmD1z xyuqi4+KK5c+oslpUBqwoXZFzHl1p3uqX2GnVzDZZmKJiu9E4DjpwPC9HK32hSJbD6Id du562k4eqCA9n8yAHPLZIMo2jyupzJpJYYM7ctTsUe/ffT9GTHzYgdhhPkV3nii8nMvU y/t00jS9/K30/pS+hGwLfcFY1najo/U6O8ha7hOwvhX181s3yJ9KV6xaPjpskOZpfcDy RhWDnLEKKML4e5nJN3lDtnOnRIbAgpcjcfVGUlhqAn2gwbKPdy5/cPG5rpE6tKRAr/14 5V3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=J3AV57GF; 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 k7si2190359edb.238.2019.10.17.11.18.04; Thu, 17 Oct 2019 11:18:27 -0700 (PDT) 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=J3AV57GF; 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 S2438669AbfJPWAB (ORCPT + 99 others); Wed, 16 Oct 2019 18:00:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:53028 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438338AbfJPV66 (ORCPT ); Wed, 16 Oct 2019 17:58:58 -0400 Received: from localhost (unknown [192.55.54.58]) (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 066C5218DE; Wed, 16 Oct 2019 21:58:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571263137; bh=uqDXuX7FvYTlA5CnBCXp8htezwOXB+LqJ3hsJ+v+GvA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J3AV57GFEUbwppWlg2Z6sCPqdyPrhnH/pncu4E3//W710xMhxwOkgq5a6j2UT6mjM C3JIS4USbtv+AyN4oxldyqC1LLlhlcI5leHYDa6c95hQ3wqx4F6cdgdRYclqR6Zox9 UXacKFb7TbO2sO8CPv/I6Km0eh2Q6XhPOF//vkcI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paul Thomas , Michal Simek Subject: [PATCH 5.3 025/112] serial: uartps: Fix uartps_major handling Date: Wed, 16 Oct 2019 14:50:17 -0700 Message-Id: <20191016214852.267606672@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191016214844.038848564@linuxfoundation.org> References: <20191016214844.038848564@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: Michal Simek commit 5e9bd2d70ae7c00a95a22994abf1eef728649e64 upstream. There are two parts which should be fixed. The first one is to assigned uartps_major at the end of probe() to avoid complicated logic when something fails. The second part is initialized uartps_major number to 0 when last device is removed. This will ensure that on next probe driver will ask for new dynamic major number. Fixes: ab262666018d ("serial: uartps: Use the same dynamic major number for all ports") Reported-by: Paul Thomas Cc: stable Signed-off-by: Michal Simek Link: https://lore.kernel.org/r/d2652cda992833315c4f96f06953eb547f928918.1570194248.git.michal.simek@xilinx.com Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/xilinx_uartps.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -1550,7 +1550,6 @@ static int cdns_uart_probe(struct platfo goto err_out_id; } - uartps_major = cdns_uart_uart_driver->tty_driver->major; cdns_uart_data->cdns_uart_driver = cdns_uart_uart_driver; /* @@ -1680,6 +1679,7 @@ static int cdns_uart_probe(struct platfo console_port = NULL; #endif + uartps_major = cdns_uart_uart_driver->tty_driver->major; cdns_uart_data->cts_override = of_property_read_bool(pdev->dev.of_node, "cts-override"); return 0; @@ -1741,6 +1741,12 @@ static int cdns_uart_remove(struct platf console_port = NULL; #endif + /* If this is last instance major number should be initialized */ + mutex_lock(&bitmap_lock); + if (bitmap_empty(bitmap, MAX_UART_INSTANCES)) + uartps_major = 0; + mutex_unlock(&bitmap_lock); + uart_unregister_driver(cdns_uart_data->cdns_uart_driver); return rc; }