mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hugo Villeneuve <hugo@hugovil.com>
To: Haoran Liu <liuhaoran14@163.com>
Cc: gregkh@linuxfoundation.org, jirislaby@kernel.org,
	linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [tty/serial] 8250_acorn: Add error handling in serial_card_probe
Date: Wed, 29 Nov 2023 09:40:56 -0500	[thread overview]
Message-ID: <20231129094056.62cf23816318e2c19400b94b@hugovil.com> (raw)
In-Reply-To: <20231129115236.33177-1-liuhaoran14@163.com>

On Wed, 29 Nov 2023 03:52:36 -0800
Haoran Liu <liuhaoran14@163.com> wrote:

Hi,
you should add a proper prefix to your patch, like:
"serial: 8250_acorn: Add..."

You can use "git log --oneline drivers/tty/serial" to have an idea on
what prefix to add.

> This patch adds error handling to the serial_card_probe
> function in drivers/tty/serial/8250/8250_acorn.c. The

You can drop the full path to the file (and also the file itself) in
your commit log message, as this information is available in the diff.

> serial8250_register_8250_port call within this function
> previously lacked proper handling for failure scenarios.
> 
> Signed-off-by: Haoran Liu <liuhaoran14@163.com>
> ---
>  drivers/tty/serial/8250/8250_acorn.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/tty/serial/8250/8250_acorn.c b/drivers/tty/serial/8250/8250_acorn.c
> index 758c4aa203ab..378ae6936028 100644
> --- a/drivers/tty/serial/8250/8250_acorn.c
> +++ b/drivers/tty/serial/8250/8250_acorn.c
> @@ -43,6 +43,7 @@ serial_card_probe(struct expansion_card *ec, const struct ecard_id *id)
>  	struct uart_8250_port uart;
>  	unsigned long bus_addr;
>  	unsigned int i;
> +	int ret;
>  
>  	info = kzalloc(sizeof(struct serial_card_info), GFP_KERNEL);
>  	if (!info)
> @@ -72,6 +73,14 @@ serial_card_probe(struct expansion_card *ec, const struct ecard_id *id)
>  		uart.port.mapbase = bus_addr + type->offset[i];
>  
>  		info->ports[i] = serial8250_register_8250_port(&uart);
> +		if (IS_ERR(info->ports[i])) {
> +			ret = PTR_ERR(info->ports[i]);
> +			while (i--)
> +				serial8250_unregister_port(info->ports[i]);
> +
> +			kfree(info);
> +			return ret;

I am just wondering if unregistering all ports in case one fails is the
correct course of action? Looking at other drivers in the same folder
(8250_exar, 8250_pericom, 8250_pci), they seem to abort registering
new ports in case of error, but do not unregister previously registered
ports?

For 8250_pci1xxxx, in case of failure the for/loop still continues...

For 8250_men_mcb however, the probe exit in case of error.

Hugo Villeneuve.


> +		}
>  	}
>  
>  	return 0;
> -- 
> 2.17.1
> 
> 

      parent reply	other threads:[~2023-11-29 14:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-29 11:52 Haoran Liu
2023-11-29 13:34 ` Greg KH
2023-11-29 14:40 ` Hugo Villeneuve [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=20231129094056.62cf23816318e2c19400b94b@hugovil.com \
    --to=hugo@hugovil.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=liuhaoran14@163.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

all inboxes | Powered by JetHome®