Message ID | 20230602064104.41508-1-tony@atomide.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp837582vqr; Thu, 1 Jun 2023 23:55:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4DIoJ3yWuiYXUCpRrLkv6s0V1/uyjWtSN/JB2H/g5V4mkUFDIXah0X/tRXxACBupb43i2w X-Received: by 2002:a05:620a:27cd:b0:75b:23a0:de9f with SMTP id i13-20020a05620a27cd00b0075b23a0de9fmr12320081qkp.29.1685688912930; Thu, 01 Jun 2023 23:55:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685688912; cv=none; d=google.com; s=arc-20160816; b=CuY2hC4AWDYmXvFE8sfsU6+UyyCrOxqVSe3x4ovAZq7i+HWDHcev7AcSiKRuycqpqM /xagoShDBUuySmsoroJ7jkG5oWCtaG2Ik08onpViL7jfaDNG0KKHFwthsejoO2JBem7k 5wJNWeu/0GMm9kTw5RtLH7dAEpmodEiduiwWjDp8IHauZevUNqoqNsLVsUfCDVfAD4d/ FHrKmIPtKQ76NX91XG3S4EJPJmQGQPMccH0FfBTXeWB58XKsrmVhnnDgrxmM41zkCS2m 2WvDo8Q6MKpECfYyrxyu0ANCcptMp4YPaVSoA2As3AOJ65Z9b8OS6T7nNUCBuF6IghmA 2MCA== 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=H9qQuZW9HEP/We4TBwXUEt0k9XHWDQTNX3/+6HRHjFI=; b=O90IeOoAvvFj9Rh/ad7EUDhG78u49TzHoaK9oZv2j5sSV5glBnP8u0cOKXTH4u4MtD ilL7CmFwL24hWSirnMP2nQT5WioVXhH2NJbAwEhWVg0KxI943YXAin2UosnuZcjZkksE OLA0StqUXwJ2Lc3SafMF8kDNo5di0pF56iA4JD6VfjcLWVzfisHmDixfN9Czmyadfyit lLf0KrU3x0WRsGODJYUkFAL4QoLUl+voQj+qOM6SN9TyMEmUmxmwEjTr79g0f4vL6wSd kxIexZOU91uTORAQl9ZrKh9Wzs1TMpdqha1PpqpZ44jHR+w/311MECB6hLT8m+yGgsNU Gx1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o22-20020a637316000000b00534897b70f9si549806pgc.29.2023.06.01.23.54.58; Thu, 01 Jun 2023 23:55:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233753AbjFBGlO (ORCPT <rfc822;limurcpp@gmail.com> + 99 others); Fri, 2 Jun 2023 02:41:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229542AbjFBGlN (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 2 Jun 2023 02:41:13 -0400 Received: from muru.com (muru.com [72.249.23.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 556CAEB; Thu, 1 Jun 2023 23:41:12 -0700 (PDT) Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id 5407D8111; Fri, 2 Jun 2023 06:41:09 +0000 (UTC) From: Tony Lindgren <tony@atomide.com> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Jiri Slaby <jirislaby@kernel.org>, Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: Andy Shevchenko <andriy.shevchenko@intel.com>, Dhruva Gole <d-gole@ti.com>, =?utf-8?q?Ilpo_J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com>, John Ogness <john.ogness@linutronix.de>, Johan Hovold <johan@kernel.org>, Sebastian Andrzej Siewior <bigeasy@linutronix.de>, Vignesh Raghavendra <vigneshr@ti.com>, linux-omap@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] serial: core: Fix error handling for serial_core_ctrl_device_add() Date: Fri, 2 Jun 2023 09:41:02 +0300 Message-ID: <20230602064104.41508-1-tony@atomide.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767572937118139230?= X-GMAIL-MSGID: =?utf-8?q?1767572937118139230?= |
Series |
serial: core: Fix error handling for serial_core_ctrl_device_add()
|
|
Commit Message
Tony Lindgren
June 2, 2023, 6:41 a.m. UTC
Checking for NULL is not enough as serial_base_ctrl_add() uses ERR_PTR().
Fixes: 84a9582fd203 ("serial: core: Start managing serial controllers to enable runtime PM")
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
drivers/tty/serial/serial_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
* Tony Lindgren <tony@atomide.com> [230602 06:41]: > Checking for NULL is not enough as serial_base_ctrl_add() uses ERR_PTR(). > > Fixes: 84a9582fd203 ("serial: core: Start managing serial controllers to enable runtime PM") > Signed-off-by: Tony Lindgren <tony@atomide.com> > --- > drivers/tty/serial/serial_core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c > --- a/drivers/tty/serial/serial_core.c > +++ b/drivers/tty/serial/serial_core.c > @@ -3342,7 +3342,7 @@ int serial_core_register_port(struct uart_driver *drv, struct uart_port *port) > ctrl_dev = serial_core_ctrl_find(drv, port->dev, port->ctrl_id); > if (!ctrl_dev) { > new_ctrl_dev = serial_core_ctrl_device_add(port); > - if (!new_ctrl_dev) { > + if (IS_ERR_OR_NULL(new_ctrl_dev)) { > ret = -ENODEV; > goto err_unlock; > } Hmm actually we should also change to use ret = PTR_ERR(new_ctrl_dev) here instead of translating all the errors to -ENODEV. Will send out v2 version. Regards, Tony
On 02. 06. 23, 8:46, Tony Lindgren wrote: > * Tony Lindgren <tony@atomide.com> [230602 06:41]: >> Checking for NULL is not enough as serial_base_ctrl_add() uses ERR_PTR(). >> >> Fixes: 84a9582fd203 ("serial: core: Start managing serial controllers to enable runtime PM") >> Signed-off-by: Tony Lindgren <tony@atomide.com> >> --- >> drivers/tty/serial/serial_core.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c >> --- a/drivers/tty/serial/serial_core.c >> +++ b/drivers/tty/serial/serial_core.c >> @@ -3342,7 +3342,7 @@ int serial_core_register_port(struct uart_driver *drv, struct uart_port *port) >> ctrl_dev = serial_core_ctrl_find(drv, port->dev, port->ctrl_id); >> if (!ctrl_dev) { >> new_ctrl_dev = serial_core_ctrl_device_add(port); >> - if (!new_ctrl_dev) { >> + if (IS_ERR_OR_NULL(new_ctrl_dev)) { >> ret = -ENODEV; >> goto err_unlock; >> } > > Hmm actually we should also change to use ret = PTR_ERR(new_ctrl_dev) here > instead of translating all the errors to -ENODEV. Will send out v2 version. Why OR_NULL at all, actually?
* Jiri Slaby <jirislaby@kernel.org> [230602 06:48]: > On 02. 06. 23, 8:46, Tony Lindgren wrote: > > * Tony Lindgren <tony@atomide.com> [230602 06:41]: > > > Checking for NULL is not enough as serial_base_ctrl_add() uses ERR_PTR(). > > > > > > Fixes: 84a9582fd203 ("serial: core: Start managing serial controllers to enable runtime PM") > > > Signed-off-by: Tony Lindgren <tony@atomide.com> > > > --- > > > drivers/tty/serial/serial_core.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c > > > --- a/drivers/tty/serial/serial_core.c > > > +++ b/drivers/tty/serial/serial_core.c > > > @@ -3342,7 +3342,7 @@ int serial_core_register_port(struct uart_driver *drv, struct uart_port *port) > > > ctrl_dev = serial_core_ctrl_find(drv, port->dev, port->ctrl_id); > > > if (!ctrl_dev) { > > > new_ctrl_dev = serial_core_ctrl_device_add(port); > > > - if (!new_ctrl_dev) { > > > + if (IS_ERR_OR_NULL(new_ctrl_dev)) { > > > ret = -ENODEV; > > > goto err_unlock; > > > } > > > > Hmm actually we should also change to use ret = PTR_ERR(new_ctrl_dev) here > > instead of translating all the errors to -ENODEV. Will send out v2 version. > > Why OR_NULL at all, actually? Yup there should be no need for that thanks. Regards, Tony
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3342,7 +3342,7 @@ int serial_core_register_port(struct uart_driver *drv, struct uart_port *port) ctrl_dev = serial_core_ctrl_find(drv, port->dev, port->ctrl_id); if (!ctrl_dev) { new_ctrl_dev = serial_core_ctrl_device_add(port); - if (!new_ctrl_dev) { + if (IS_ERR_OR_NULL(new_ctrl_dev)) { ret = -ENODEV; goto err_unlock; }