From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C854C43381 for ; Fri, 8 Mar 2019 13:58:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 423DF20851 for ; Fri, 8 Mar 2019 13:58:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726902AbfCHN6t (ORCPT ); Fri, 8 Mar 2019 08:58:49 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:4659 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726613AbfCHN6s (ORCPT ); Fri, 8 Mar 2019 08:58:48 -0500 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 05A8D9B9B7CF1E941FBF; Fri, 8 Mar 2019 21:58:46 +0800 (CST) Received: from [127.0.0.1] (10.177.96.96) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.408.0; Fri, 8 Mar 2019 21:58:43 +0800 Subject: Re: [PATCH serial] sc16is7xx: missing unregister/delete driver on error in sc16is7xx_init() To: , , , , References: <20190308140933.55262-1-maowenan@huawei.com> From: maowenan Message-ID: Date: Fri, 8 Mar 2019 21:58:27 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <20190308140933.55262-1-maowenan@huawei.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.96.96] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org sorry for duplicate mail, please ignore this one. On 2019/3/8 22:09, Mao Wenan wrote: > Add the missing uart_unregister_driver() and i2c_del_driver() before return > from sc16is7xx_init() in the error handling case. > > Signed-off-by: Mao Wenan > --- > drivers/tty/serial/sc16is7xx.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c > index 268098681856..114e94f476c6 100644 > --- a/drivers/tty/serial/sc16is7xx.c > +++ b/drivers/tty/serial/sc16is7xx.c > @@ -1509,7 +1509,7 @@ static int __init sc16is7xx_init(void) > ret = i2c_add_driver(&sc16is7xx_i2c_uart_driver); > if (ret < 0) { > pr_err("failed to init sc16is7xx i2c --> %d\n", ret); > - return ret; > + goto err_i2c; > } > #endif > > @@ -1517,10 +1517,18 @@ static int __init sc16is7xx_init(void) > ret = spi_register_driver(&sc16is7xx_spi_uart_driver); > if (ret < 0) { > pr_err("failed to init sc16is7xx spi --> %d\n", ret); > - return ret; > + goto err_spi; > } > #endif > return ret; > + > +err_spi: > +#ifdef CONFIG_SERIAL_SC16IS7XX_I2C > + i2c_del_driver(&sc16is7xx_i2c_uart_driver); > +#endif > +err_i2c: > + uart_unregister_driver(&sc16is7xx_uart); > + return ret; > } > module_init(sc16is7xx_init); > >