From patchwork Thu Jun 30 14:09:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 586742 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BC19CCA480 for ; Thu, 30 Jun 2022 14:14:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236935AbiF3OOI (ORCPT ); Thu, 30 Jun 2022 10:14:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236911AbiF3ONo (ORCPT ); Thu, 30 Jun 2022 10:13:44 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D29FB3BBEF; Thu, 30 Jun 2022 06:59:31 -0700 (PDT) Received: from dggpemm500021.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LYfyt48lDzhYq0; Thu, 30 Jun 2022 21:57:10 +0800 (CST) Received: from dggpemm500007.china.huawei.com (7.185.36.183) by dggpemm500021.china.huawei.com (7.185.36.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 30 Jun 2022 21:59:28 +0800 Received: from huawei.com (10.175.103.91) by dggpemm500007.china.huawei.com (7.185.36.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 30 Jun 2022 21:59:28 +0800 From: Yang Yingliang To: , CC: , , , Subject: [PATCH 1/2] serial: sh-sci: fix missing sci_cleanup_single() in sci_probe_single() Date: Thu, 30 Jun 2022 22:09:18 +0800 Message-ID: <20220630140919.3857698-1-yangyingliang@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Add missing sci_cleanup_single() in error case in sci_probe_single() Fixes: f907c9ea8835 ("serial: sh-sci: Add support for GPIO-controlled modem lines") Reported-by: Hulk Robot Signed-off-by: Yang Yingliang --- drivers/tty/serial/sh-sci.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 0075a1420005..ca5a58f01aff 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -3283,25 +3283,31 @@ static int sci_probe_single(struct platform_device *dev, return ret; sciport->gpios = mctrl_gpio_init(&sciport->port, 0); - if (IS_ERR(sciport->gpios)) - return PTR_ERR(sciport->gpios); + if (IS_ERR(sciport->gpios)) { + ret = PTR_ERR(sciport->gpios); + goto err_cleanup_single; + } if (sciport->has_rtscts) { if (mctrl_gpio_to_gpiod(sciport->gpios, UART_GPIO_CTS) || mctrl_gpio_to_gpiod(sciport->gpios, UART_GPIO_RTS)) { dev_err(&dev->dev, "Conflicting RTS/CTS config\n"); - return -EINVAL; + ret = -EINVAL; + goto err_cleanup_single; } sciport->port.flags |= UPF_HARD_FLOW; } ret = uart_add_one_port(&sci_uart_driver, &sciport->port); - if (ret) { - sci_cleanup_single(sciport); - return ret; - } + if (ret) + goto err_cleanup_single; return 0; + +err_cleanup_single: + sci_cleanup_single(sciport); + + return ret; } static int sci_probe(struct platform_device *dev) From patchwork Thu Jun 30 14:09:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 586285 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97D85C433EF for ; Thu, 30 Jun 2022 14:14:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237127AbiF3OOI (ORCPT ); Thu, 30 Jun 2022 10:14:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236932AbiF3ONp (ORCPT ); Thu, 30 Jun 2022 10:13:45 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FB013EAB8; Thu, 30 Jun 2022 06:59:34 -0700 (PDT) Received: from dggpemm500020.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4LYfyv32NDz1L8fD; Thu, 30 Jun 2022 21:57:11 +0800 (CST) Received: from dggpemm500007.china.huawei.com (7.185.36.183) by dggpemm500020.china.huawei.com (7.185.36.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 30 Jun 2022 21:59:29 +0800 Received: from huawei.com (10.175.103.91) by dggpemm500007.china.huawei.com (7.185.36.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 30 Jun 2022 21:59:28 +0800 From: Yang Yingliang To: , CC: , , , Subject: [PATCH 2/2] serial: sh-sci: fix missing uart_unregister_driver() in sci_probe_single() Date: Thu, 30 Jun 2022 22:09:19 +0800 Message-ID: <20220630140919.3857698-2-yangyingliang@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220630140919.3857698-1-yangyingliang@huawei.com> References: <20220630140919.3857698-1-yangyingliang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Add missing uart_unregister_driver() in error case in sci_probe_single(). Fixes: 352b92664549 ("serial: sh-sci: Move uart_register_driver call to device probe") Reported-by: Hulk Robot Signed-off-by: Yang Yingliang --- drivers/tty/serial/sh-sci.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index ca5a58f01aff..08a249eaaa8c 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -3280,7 +3280,7 @@ static int sci_probe_single(struct platform_device *dev, ret = sci_init_single(dev, sciport, index, p, false); if (ret) - return ret; + goto err_unregister; sciport->gpios = mctrl_gpio_init(&sciport->port, 0); if (IS_ERR(sciport->gpios)) { @@ -3306,6 +3306,10 @@ static int sci_probe_single(struct platform_device *dev, err_cleanup_single: sci_cleanup_single(sciport); +err_unregister: + mutex_lock(&sci_uart_registration_lock); + uart_unregister_driver(&sci_uart_driver); + mutex_unlock(&sci_uart_registration_lock); return ret; }