From patchwork Mon Oct 8 12:17:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 10630581 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 63FEA15E2 for ; Mon, 8 Oct 2018 12:28:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5385C28D87 for ; Mon, 8 Oct 2018 12:28:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4769B28DB2; Mon, 8 Oct 2018 12:28:04 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8B17328D87 for ; Mon, 8 Oct 2018 12:28:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=7OjOJA6pwnKvpQCwSfCUbVeMICs6U4Rw99stjBHGZ3k=; b=ez8 ngoR/rSnZPY+v5Gd4Dub+gfm0d7eaqyjmwJL8lxheqkbM+Vfa/NDy6uevGcBBA04dK4hN4s5Uw3GW 7a2QRA+z6w1fWxSVE6IK50v6kGU0u3kPMNoDxMdAxPOWwbznEPPwTzMjtUwZFxjwHxrAzwLZUEC62 wTrBA0Tgntiuc7XVkrAgP+1idnEd8r0C1Ay8fQIlZc9RWLi8B8P4qVtHD7jwJ/BiXLL2qRs7Tj2bW 4zMCm0AOia0L6vvqCS0KFyV/zjTNhlo/t/ruVsse1JuZXMeEmjbtGodw8EBGFPXLhJytaZhH+KOC6 p39klcLc7wj0I6zYyD/AGvilavswpUg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9UdZ-0008W1-QY; Mon, 08 Oct 2018 12:27:50 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9UcS-0007e2-8q for linux-arm-kernel@bombadil.infradead.org; Mon, 08 Oct 2018 12:26:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=vVuFMlihYr6DWRxThKteT20nApP3XsywkcmTmPCEflI=; b=qhY/HZhywcojryT8NQz5iJPSv amwIpLv1xXmwUarO9bGx8fE0vwqrhohaaJmgVUq36um9DikmqW1+97FmGeV8Ktg6KRO5k8YBJgNnG L4QXOh9daxMlD4ASvaEqLPLfYYxKkz/gVqgESHCyms1Si2YSAvlOvbvsN4bLjxz/qOUrgzl0R6x0I In1LRkJywDX43efOUvwULgyJvV5i5rT/NOJuDwZiRBaZ6yT7v3kRB9ocEt9t6TprfeaV0MKwyd6jW BT9ybY73j3aONJARTa5BfnDGtJnHN9+aIelMiFfY9uWMdkmY8wY76/6hBGpq9FOwfKeFXCFsw/yEG Aa9QYqBBA==; Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9UTc-0001u0-Ir for linux-arm-kernel@lists.infradead.org; Mon, 08 Oct 2018 12:17:34 +0000 Received: by mail-wr1-x441.google.com with SMTP id a2-v6so13499589wrc.13 for ; Mon, 08 Oct 2018 05:17:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id; bh=vVuFMlihYr6DWRxThKteT20nApP3XsywkcmTmPCEflI=; b=H7ObzLCy/ZCfPbs/Dk0v2jk4CHN2RHqQlm+4dnnrbeQV7d57VesngOki8gCqJiALMr qlgwMp3hXOZogHWNdNfz2VDm50yzyh0UuukyqBxYKBo33szufcDIp+MKjcAAC6Ii52U+ syeKzeOKYAz+tny/IG+swVjq3te5EzbgLDYKm2vXjfpNAOKhNBTSavcG3yFGr2Xq9o6L JO6ij9zOKEjSH4DXgyP+ATzV2EJyizf38NhsotUZal7a0hJS1FKhBki2D4IwbKAo0pjF d2ecfvz0aO/Z78/fEloRzZibzpaGFP5CQbIqp6occrycH4sB2/YGG1BWMqry3Yq1lHmT KZPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=vVuFMlihYr6DWRxThKteT20nApP3XsywkcmTmPCEflI=; b=GU+ybAaC+gmjIE7zSrVudn9xdSneuJBfENZQxBIFKJmtj3vZQN8IbppdgXDL31PyVj 4i7cpnbYCzQE1NkW+ikPKZq+YRJa15yggUsRmw6J6EIstL6a++t3EBDKS2FFfGCR+ITE guK30MZSKOvpkvoiKkW0WT8UJvUgtFpChUoCb9c26rhyxGdNRbbBl5kAUD9QTleHf45S DM8kTPx/RZySA3eq5pFGTesScMkNHrwMln9VbJsL8U4GqYljrpbQF6P0uMsr0WRuligM 860X2Ub+4mUNcGiMQg6yI+RTcgvHFtkWUz9Yv8cUIqpLy8zjZcuz4m2EvL4DrJg+qWhA k6+A== X-Gm-Message-State: ABuFfoiQK6Z4kOQ5y7IoONHH5MZO2+fPHBM4stj6bvBSyzcmy2gbCKaC nnaUGht90KTnxTALtvRj6Q96Sg== X-Google-Smtp-Source: ACcGV62N2F+bZgV1J24sHxF5eD6E4Yigry8pvIcnaCNd6hMOcbV8woAkGYLSAXivFBDfKu+sVh9E/w== X-Received: by 2002:adf:f5c6:: with SMTP id k6-v6mr16339704wrp.59.1539001040786; Mon, 08 Oct 2018 05:17:20 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id n68-v6sm7494634wmn.5.2018.10.08.05.17.20 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 08 Oct 2018 05:17:20 -0700 (PDT) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu, geert@linux-m68k.org, gregkh@linuxfoundation.org Subject: [PATCH] serial: uartps: Do not allow use aliases >= MAX_UART_INSTANCES Date: Mon, 8 Oct 2018 14:17:19 +0200 Message-Id: <01aec25ae2cee7857d92140e98fde1da28393937.1539001037.git.michal.simek@xilinx.com> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181008_131732_613193_5B5B0CA1 X-CRM114-Status: GOOD ( 14.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, linux-serial@vger.kernel.org, Jiri Slaby MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Aliases >= MAX_UART_INSTANCES is no problem to find out and use but in error path is necessary skip clearing bits in bitmap to ensure that only bits in allocated bitmap are handled and nothing beyond that. Without this patch when for example serial90 alias is used then in error patch bit 90 is clear in 32bit wide bitmap. Fixes: ae1cca3fa347 ("serial: uartps: Change uart ID port allocation") Signed-off-by: Michal Simek --- Based on tty-next tree. --- drivers/tty/serial/xilinx_uartps.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index e82d1d56399f..29a18103182d 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -1673,7 +1673,8 @@ static int cdns_uart_probe(struct platform_device *pdev) uart_unregister_driver(cdns_uart_data->cdns_uart_driver); err_out_id: mutex_lock(&bitmap_lock); - clear_bit(cdns_uart_data->id, bitmap); + if (cdns_uart_data->id < MAX_UART_INSTANCES) + clear_bit(cdns_uart_data->id, bitmap); mutex_unlock(&bitmap_lock); return rc; } @@ -1698,7 +1699,8 @@ static int cdns_uart_remove(struct platform_device *pdev) rc = uart_remove_one_port(cdns_uart_data->cdns_uart_driver, port); port->mapbase = 0; mutex_lock(&bitmap_lock); - clear_bit(cdns_uart_data->id, bitmap); + if (cdns_uart_data->id < MAX_UART_INSTANCES) + clear_bit(cdns_uart_data->id, bitmap); mutex_unlock(&bitmap_lock); clk_disable_unprepare(cdns_uart_data->uartclk); clk_disable_unprepare(cdns_uart_data->pclk);