linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stafford Horne <shorne@gmail.com>
To: Johan Hovold <johan@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Ilia Sergachev <silia@ethz.ch>,
	Karol Gugala <kgugala@antmicro.com>,
	Mateusz Holenko <mholenko@antmicro.com>,
	linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org,
	Filip Kokosinski <fkokosinski@antmicro.com>
Subject: Re: [PATCH 3/3] serial: liteuart: fix minor-number leak on probe errors
Date: Tue, 16 Nov 2021 06:16:07 +0900	[thread overview]
Message-ID: <YZLOF2g8DBllJg2l@antec> (raw)
In-Reply-To: <20211115133745.11445-4-johan@kernel.org>

On Mon, Nov 15, 2021 at 02:37:45PM +0100, Johan Hovold wrote:
> Make sure to release the allocated minor number before returning on
> probe errors.
> 
> Fixes: 1da81e5562fa ("drivers/tty/serial: add LiteUART driver")
> Cc: stable@vger.kernel.org      # 5.11
> Cc: Filip Kokosinski <fkokosinski@antmicro.com>
> Cc: Mateusz Holenko <mholenko@antmicro.com>
> Cc: Stafford Horne <shorne@gmail.com>
> Signed-off-by: Johan Hovold <johan@kernel.org>

Reviewed-by: Stafford Horne <shorne@gmail.com>

> ---
>  drivers/tty/serial/liteuart.c | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c
> index da792d0df790..2941659e5274 100644
> --- a/drivers/tty/serial/liteuart.c
> +++ b/drivers/tty/serial/liteuart.c
> @@ -270,8 +270,10 @@ static int liteuart_probe(struct platform_device *pdev)
>  
>  	/* get membase */
>  	port->membase = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
> -	if (IS_ERR(port->membase))
> -		return PTR_ERR(port->membase);
> +	if (IS_ERR(port->membase)) {
> +		ret = PTR_ERR(port->membase);
> +		goto err_erase_id;
> +	}
>  
>  	/* values not from device tree */
>  	port->dev = &pdev->dev;
> @@ -287,7 +289,16 @@ static int liteuart_probe(struct platform_device *pdev)
>  
>  	platform_set_drvdata(pdev, port);
>  
> -	return uart_add_one_port(&liteuart_driver, &uart->port);
> +	ret = uart_add_one_port(&liteuart_driver, &uart->port);
> +	if (ret)
> +		goto err_erase_id;
> +
> +	return 0;
> +
> +err_erase_id:
> +	xa_erase(&liteuart_array, uart->id);
> +
> +	return ret;
>  }
>  
>  static int liteuart_remove(struct platform_device *pdev)
> -- 
> 2.32.0
> 

      reply	other threads:[~2021-11-15 21:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-15 13:37 [PATCH 0/3] serial: liteuart: fix compile testing and driver unbind Johan Hovold
2021-11-15 13:37 ` [PATCH 1/3] serial: liteuart: fix compile testing Johan Hovold
2021-11-15 21:15   ` Stafford Horne
2021-11-16 15:44   ` Andy Shevchenko
2021-11-17  9:06     ` Johan Hovold
2021-11-15 13:37 ` [PATCH 2/3] serial: liteuart: fix use-after-free and memleak on unbind Johan Hovold
2021-11-15 21:15   ` Stafford Horne
2021-11-16  7:06     ` Johan Hovold
2021-11-15 13:37 ` [PATCH 3/3] serial: liteuart: fix minor-number leak on probe errors Johan Hovold
2021-11-15 21:16   ` Stafford Horne [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=YZLOF2g8DBllJg2l@antec \
    --to=shorne@gmail.com \
    --cc=fkokosinski@antmicro.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=johan@kernel.org \
    --cc=kgugala@antmicro.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=mholenko@antmicro.com \
    --cc=silia@ethz.ch \
    --cc=stable@vger.kernel.org \
    /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).