From: Greg KH <gregkh@linuxfoundation.org>
To: Yuan Can <yuancan@huawei.com>
Cc: jirislaby@kernel.org, shc_work@mail.ru, arnd@arndb.de,
linux-serial@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] serial: clps711x: Fix error handling in uart_clps711x_init()
Date: Thu, 19 Jan 2023 16:03:20 +0100 [thread overview]
Message-ID: <Y8lbuHVwmnH+DXtn@kroah.com> (raw)
In-Reply-To: <20221124061236.31050-1-yuancan@huawei.com>
On Thu, Nov 24, 2022 at 06:12:36AM +0000, Yuan Can wrote:
> The uart_clps711x_init() returns the platform_driver_register() directly
> without checking its return value, if platform_driver_register() failed,
> the clps711x_uart is not unregistered.
>
> Fix by unregister clps711x_uart when platform_driver_register() failed.
>
> Fixes: bc00024502ed ("serial: clps711x: Driver refactor")
> Signed-off-by: Yuan Can <yuancan@huawei.com>
> ---
> drivers/tty/serial/clps711x.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/clps711x.c b/drivers/tty/serial/clps711x.c
> index 404b43a5ae33..d6284244da1d 100644
> --- a/drivers/tty/serial/clps711x.c
> +++ b/drivers/tty/serial/clps711x.c
> @@ -546,7 +546,13 @@ static int __init uart_clps711x_init(void)
> if (ret)
> return ret;
>
> - return platform_driver_register(&clps711x_uart_platform);
> + ret = platform_driver_register(&clps711x_uart_platform);
> + if (ret) {
> + uart_unregister_driver(&clps711x_uart);
> + return ret;
> + }
> +
> + return 0;
Minot nit, but this can be cleaned up to be even smaller:
ret = platform_driver_register(&clps711x_uart_platform);
if (ret)
uart_unregister_driver(&clps711x_uart);
return ret;
thanks,
greg k-h
prev parent reply other threads:[~2023-01-19 15:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-24 6:12 [PATCH] serial: clps711x: Fix error handling in uart_clps711x_init() Yuan Can
2023-01-19 15:03 ` Greg KH [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y8lbuHVwmnH+DXtn@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=arnd@arndb.de \
--cc=jirislaby@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-serial@vger.kernel.org \
--cc=shc_work@mail.ru \
--cc=yuancan@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).