Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2477927rdb; Wed, 4 Oct 2023 02:21:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IESwztllXCh8fMiLddwfMZ5k3Oeb39rSj+x+EF6vv6MgR0erl4aw8YD9nL6397S0mqAOhkq X-Received: by 2002:a05:6358:3418:b0:142:fb25:c7e6 with SMTP id h24-20020a056358341800b00142fb25c7e6mr1688023rwd.13.1696411300612; Wed, 04 Oct 2023 02:21:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696411300; cv=none; d=google.com; s=arc-20160816; b=ElId0eK/+W1KIUOj9Y9eZDZoqUXMbQGsv4HXX+w7RzxgnAWROoU5UdbdR2Eg3Atvc1 g+6vrE3E9KYBHkYcIuOHc91VuPhivDXTXcFyHWfjGiY2cJ5NaYrc9iQZt/8KpWHg1QGE 6Y0RbMAmN0yGvzxvpL+AGfdQ87YavVei+9rlCUdOwROTw6QUsjyKVWH09RogwOKZ6lF9 oWlmImTJlBnktK4rCRYCoXOhvkiIXdtS88oQLry7nonibBZlavv0Vho48OGJrTMukdfE Z1DXeAktjfUITgY80fE+ZbufrP8VX+I+FFuVVvh0H5ASnQk4NmBxn8TdH01UXKF5MmPw GmqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=2Sp59vorNL39GeiX3D1tF/roLOcuQI8FZVrDLhLdBWA=; fh=4LMwDg9iDtsRgrORVjX5sXAX+/NhtFQsb9g5eBe+3KY=; b=hurJnsBcd2wobifGOeWXA7YWm4eoBmAaaPI3Gnt0xaRuqBzU4Bj/LJgvF9AK4dIMXo n4HyNYgOja0XrbTb32y8dqPxg/uQvBRaI8MUlJ8lS4B3Ilphd2ApFdXydPsiX0Zp4aOt +SW0JREG5vK1yAb8Z7brGuECUbFYK2Dqp6FIwxaIe2GZOeqJNN3tUn5iA5ezKOSLP9M5 jCPuzp6xEbGjSspBSqRGsYE7IsHejloQq8dqE0s4+0zhZPmM0BwA5LJ6Vx7CLnhVvrQw BTSWcP8heeBw8S3hs3P9Da3MrR+12Qjk71WKCTGI8kJgoQDrPM5EQHdGPjr+j3irZWLB kRLQ== 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:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id oo5-20020a17090b1c8500b0026d6ad52473si1281916pjb.34.2023.10.04.02.21.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 02:21:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 7D18E81E9A57; Wed, 4 Oct 2023 02:21:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233056AbjJDJVi (ORCPT + 99 others); Wed, 4 Oct 2023 05:21:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232810AbjJDJVg (ORCPT ); Wed, 4 Oct 2023 05:21:36 -0400 Received: from muru.com (muru.com [72.249.23.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DED7C9E; Wed, 4 Oct 2023 02:21:33 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTPS id 2FD4780BD; Wed, 4 Oct 2023 09:21:33 +0000 (UTC) Date: Wed, 4 Oct 2023 12:21:31 +0300 From: Tony Lindgren To: Ilpo =?utf-8?B?SsOkcnZpbmVu?= Cc: Greg Kroah-Hartman , Jiri Slaby , Andy Shevchenko , Dhruva Gole , John Ogness , Johan Hovold , Sebastian Andrzej Siewior , Vignesh Raghavendra , LKML , linux-serial Subject: Re: [PATCH] serial: 8250: Check for valid console index Message-ID: <20231004092131.GG34982@atomide.com> References: <20231004085511.42645-1-tony@atomide.com> <1fc2dc1d-33f2-6d65-6bdb-d4c7421cbc57@linux.intel.com> <20231004090859.GF34982@atomide.com> <375d54d0-f874-92d5-91c5-c7ff2b33daff@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <375d54d0-f874-92d5-91c5-c7ff2b33daff@linux.intel.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 04 Oct 2023 02:21:39 -0700 (PDT) * Ilpo Järvinen [231004 09:13]: > On Wed, 4 Oct 2023, Tony Lindgren wrote: > > > * Ilpo Järvinen [231004 09:05]: > > > On Wed, 4 Oct 2023, Tony Lindgren wrote: > > > > > > > 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; > > > > > > The inconsistencies how different serial drivers handle this situation > > > seem staggering. Perhaps there should be some effort to make the behavior > > > uniform across them? > > > > Hmm yeah we should just have them all check for co->index < 0. > > Right but it's only about that, some return -Exx codes (more than one -Exx > variant) and some do assign just 0 like here. What do you have in mind then? They should all assume co->index < 0 is an invalid console index still, right :) Regards, Tony