linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Yi Yang <yiyang13@huawei.com>
Cc: jirislaby@kernel.org, nicolas.ferre@microchip.com,
	alexandre.belloni@bootlin.com, claudiu.beznea@tuxon.dev,
	linux-serial@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] serial: atmel: Check return value of platform_get_irq() in atmel_init_port()
Date: Sat, 21 Oct 2023 18:16:32 +0200	[thread overview]
Message-ID: <2023102151-mobster-reappoint-99da@gregkh> (raw)
In-Reply-To: <20231018091521.314706-1-yiyang13@huawei.com>

On Wed, Oct 18, 2023 at 09:15:21AM +0000, Yi Yang wrote:
> The platform_get_irq() might be failed and return a negative result, there
> should be return an error code when platform_get_irq() failed.
> Fix it by add check return value of platform_get_irq().
> 
> Fixes: 5bb221b0ad65 ("serial: atmel: Use platform_get_irq() to get the interrupt")
> Signed-off-by: Yi Yang <yiyang13@huawei.com>
> ---
>  drivers/tty/serial/atmel_serial.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
> index 1946fafc3f3e..4984bec88445 100644
> --- a/drivers/tty/serial/atmel_serial.c
> +++ b/drivers/tty/serial/atmel_serial.c
> @@ -2540,13 +2540,17 @@ static int atmel_init_port(struct atmel_uart_port *atmel_port,
>  	atmel_init_property(atmel_port, pdev);
>  	atmel_set_ops(port);
>  
> +	ret = platform_get_irq(mpdev, 0);
> +	if (ret < 0)
> +		return 0;
> +
>  	port->iotype		= UPIO_MEM;
>  	port->flags		= UPF_BOOT_AUTOCONF | UPF_IOREMAP;
>  	port->ops		= &atmel_pops;
>  	port->fifosize		= 1;
>  	port->dev		= &pdev->dev;
>  	port->mapbase		= mpdev->resource[0].start;
> -	port->irq		= platform_get_irq(mpdev, 0);
> +	port->irq		= ret;

Sorry, no, this makes things much more complex and error-prone in the
long term, for a function that in reality, never fails (obviously
otherwise this would have been reported.)

How did you test this?

thanks,

greg k-h

      reply	other threads:[~2023-10-21 16:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-18  9:15 [PATCH] serial: atmel: Check return value of platform_get_irq() in atmel_init_port() Yi Yang
2023-10-21 16:16 ` 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=2023102151-mobster-reappoint-99da@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=jirislaby@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=nicolas.ferre@microchip.com \
    --cc=yiyang13@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).