From patchwork Wed Oct 4 08:55:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 148181 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp2616634vqb; Wed, 4 Oct 2023 01:55:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHd2k47JukU3ajSK5Tevdieq/mcW/Bvc7IQI/ABer5wP6mrwibu2vsuG2IgsG6U8JF4klHr X-Received: by 2002:a05:6a20:a11a:b0:15b:b83c:9b48 with SMTP id q26-20020a056a20a11a00b0015bb83c9b48mr7489814pzk.24.1696409755799; Wed, 04 Oct 2023 01:55:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696409755; cv=none; d=google.com; s=arc-20160816; b=rtFV7JdZUoFCJoGC9j5zlnwttKVumWhdpcCP5VQ8zM+CTuHoH4nLNCP0YR1I8/dRrL 9wSN0/FxFHxo77BLv9KXzS1W2fGRV4Q762th0Z55EKqgg7d/rQ8iR4YOHhmJitEoI9Pr rj+yVYPTcS41/80s6KQq/uf/u9uMjTUpSR9GNXcr6g86E1FcwPjDxtu21A6qsHhQW3kq heUTEdCx34MMk1IIeR6urZREOs3IKD4te+1Y2X7ltgTwuOlPzSM3NpMTwaLV/+xeUz+s 7Z36iccGvAbVgoDaqVIvQtmsRGiNLI4xzoANgVrn8zovS+RBfYBW0sgj6Ad3ESwgtjbv WpXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=ATijuH7y5H6PUEJoPopW/MkDQejPGnsTpnLhmAD4eWk=; fh=n7dM+f7LjYuLx+o4gzxXNkEWC9u7qeJi6cmcRDZcVew=; b=pyH/7ugpjJzV38B8joZUwVylS6PSTcANsjx1R9sqy0MaILl9EM37rlU2xc0PcxVLlt biUCxR3Id0iVX4fyfSMJ0yyGTUOorvA1KEqyx4nH0ks/83HKMKWfTgeFqFv36Z8ITzMS ElMSYe4N5hQ7b1umE2YX/Cb4i7sFtbNF5hnZLF3oexpuWUUV53PAO3NzZaOaZvw9ksmw RRoW8u1NTVGsuRlo/HYREF1ZQ3erOdye56CoL8EuQXc5c3A1wJPXS7aHIviC1kzB3ad8 56dQWXpoVTnhEXMWwvkuHciZpe9QCCNllpSkNM1Q6oyxLh14WOLMecqhyueXNMTCF+E/ 0LoQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id u190-20020a6385c7000000b00582f2161cb4si3509254pgd.300.2023.10.04.01.55.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 01:55:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id DBF8581AAE4B; Wed, 4 Oct 2023 01:55:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241828AbjJDIzj (ORCPT + 18 others); Wed, 4 Oct 2023 04:55:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232554AbjJDIzi (ORCPT ); Wed, 4 Oct 2023 04:55:38 -0400 Received: from muru.com (unknown [72.249.23.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 90EF3A6; Wed, 4 Oct 2023 01:55:32 -0700 (PDT) Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id 7C273810D; Wed, 4 Oct 2023 08:55:15 +0000 (UTC) From: Tony Lindgren To: Greg Kroah-Hartman , Jiri Slaby Cc: Andy Shevchenko , Dhruva Gole , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , John Ogness , Johan Hovold , Sebastian Andrzej Siewior , Vignesh Raghavendra , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: [PATCH] serial: 8250: Check for valid console index Date: Wed, 4 Oct 2023 11:55:10 +0300 Message-ID: <20231004085511.42645-1-tony@atomide.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 04 Oct 2023 01:55:53 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778814555955682316 X-GMAIL-MSGID: 1778814555955682316 Let's not allow negative numbers for console index. Signed-off-by: Tony Lindgren --- drivers/tty/serial/8250/8250_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c --- a/drivers/tty/serial/8250/8250_core.c +++ b/drivers/tty/serial/8250/8250_core.c @@ -611,7 +611,7 @@ static int univ8250_console_setup(struct console *co, char *options) * if so, search for the first available port that does have * console support. */ - if (co->index >= UART_NR) + if (co->index < 0 || co->index >= UART_NR) co->index = 0; /*