Linux-Serial Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2] serial: mxs-auart: add missed iounmap() in probe failure and remove
@ 2020-07-09 13:56 Chuhong Yuan
  2020-07-14 11:29 ` Jiri Slaby
  0 siblings, 1 reply; 2+ messages in thread
From: Chuhong Yuan @ 2020-07-09 13:56 UTC (permalink / raw)
  Cc: Greg Kroah-Hartman, Jiri Slaby, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team,
	linux-serial, linux-arm-kernel, linux-kernel, Chuhong Yuan

This driver calls ioremap() in probe, but it misses calling iounmap() in 
probe's error handler and remove.
Add the missed calls to fix it.

Fixes: 47d37d6f94cc ("serial: Add auart driver for i.MX23/28")
Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
---
Changes in v2:
  - Use iounmap() instead of devm_ioremap() to fix the bugs.
  - Modify the subject and the description.

 drivers/tty/serial/mxs-auart.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index b4f835e7de23..b784323a6a7b 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -1698,21 +1698,21 @@ static int mxs_auart_probe(struct platform_device *pdev)
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		ret = irq;
-		goto out_disable_clks;
+		goto out_iounmap;
 	}
 
 	s->port.irq = irq;
 	ret = devm_request_irq(&pdev->dev, irq, mxs_auart_irq_handle, 0,
 			       dev_name(&pdev->dev), s);
 	if (ret)
-		goto out_disable_clks;
+		goto out_iounmap;
 
 	platform_set_drvdata(pdev, s);
 
 	ret = mxs_auart_init_gpios(s, &pdev->dev);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to initialize GPIOs.\n");
-		goto out_disable_clks;
+		goto out_iounmap;
 	}
 
 	/*
@@ -1720,7 +1720,7 @@ static int mxs_auart_probe(struct platform_device *pdev)
 	 */
 	ret = mxs_auart_request_gpio_irq(s);
 	if (ret)
-		goto out_disable_clks;
+		goto out_iounmap;
 
 	auart_port[s->port.line] = s;
 
@@ -1746,6 +1746,9 @@ static int mxs_auart_probe(struct platform_device *pdev)
 	mxs_auart_free_gpio_irq(s);
 	auart_port[pdev->id] = NULL;
 
+out_iounmap:
+	iounmap(s->port.membase);
+
 out_disable_clks:
 	if (is_asm9260_auart(s)) {
 		clk_disable_unprepare(s->clk);
@@ -1761,6 +1764,7 @@ static int mxs_auart_remove(struct platform_device *pdev)
 	uart_remove_one_port(&auart_driver, &s->port);
 	auart_port[pdev->id] = NULL;
 	mxs_auart_free_gpio_irq(s);
+	iounmap(s->port.membase);
 	if (is_asm9260_auart(s)) {
 		clk_disable_unprepare(s->clk);
 		clk_disable_unprepare(s->clk_ahb);
-- 
2.26.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] serial: mxs-auart: add missed iounmap() in probe failure and remove
  2020-07-09 13:56 [PATCH v2] serial: mxs-auart: add missed iounmap() in probe failure and remove Chuhong Yuan
@ 2020-07-14 11:29 ` Jiri Slaby
  0 siblings, 0 replies; 2+ messages in thread
From: Jiri Slaby @ 2020-07-14 11:29 UTC (permalink / raw)
  To: Chuhong Yuan
  Cc: Greg Kroah-Hartman, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team,
	linux-serial, linux-arm-kernel, linux-kernel

On 09. 07. 20, 15:56, Chuhong Yuan wrote:
> This driver calls ioremap() in probe, but it misses calling iounmap() in 
> probe's error handler and remove.
> Add the missed calls to fix it.
> 
> Fixes: 47d37d6f94cc ("serial: Add auart driver for i.MX23/28")
> Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
> ---
> Changes in v2:
>   - Use iounmap() instead of devm_ioremap() to fix the bugs.

Out of curiosity, what was wrong with devm_ioremap? I seem I cannot find
the reason...

>   - Modify the subject and the description.
> 
>  drivers/tty/serial/mxs-auart.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
> index b4f835e7de23..b784323a6a7b 100644
> --- a/drivers/tty/serial/mxs-auart.c
> +++ b/drivers/tty/serial/mxs-auart.c
> @@ -1698,21 +1698,21 @@ static int mxs_auart_probe(struct platform_device *pdev)
>  	irq = platform_get_irq(pdev, 0);
>  	if (irq < 0) {
>  		ret = irq;
> -		goto out_disable_clks;
> +		goto out_iounmap;
>  	}
>  
>  	s->port.irq = irq;
>  	ret = devm_request_irq(&pdev->dev, irq, mxs_auart_irq_handle, 0,
>  			       dev_name(&pdev->dev), s);
>  	if (ret)
> -		goto out_disable_clks;
> +		goto out_iounmap;
>  
>  	platform_set_drvdata(pdev, s);
>  
>  	ret = mxs_auart_init_gpios(s, &pdev->dev);
>  	if (ret) {
>  		dev_err(&pdev->dev, "Failed to initialize GPIOs.\n");
> -		goto out_disable_clks;
> +		goto out_iounmap;
>  	}
>  
>  	/*
> @@ -1720,7 +1720,7 @@ static int mxs_auart_probe(struct platform_device *pdev)
>  	 */
>  	ret = mxs_auart_request_gpio_irq(s);
>  	if (ret)
> -		goto out_disable_clks;
> +		goto out_iounmap;
>  
>  	auart_port[s->port.line] = s;
>  
> @@ -1746,6 +1746,9 @@ static int mxs_auart_probe(struct platform_device *pdev)
>  	mxs_auart_free_gpio_irq(s);
>  	auart_port[pdev->id] = NULL;
>  
> +out_iounmap:
> +	iounmap(s->port.membase);
> +
>  out_disable_clks:
>  	if (is_asm9260_auart(s)) {
>  		clk_disable_unprepare(s->clk);
> @@ -1761,6 +1764,7 @@ static int mxs_auart_remove(struct platform_device *pdev)
>  	uart_remove_one_port(&auart_driver, &s->port);
>  	auart_port[pdev->id] = NULL;
>  	mxs_auart_free_gpio_irq(s);
> +	iounmap(s->port.membase);
>  	if (is_asm9260_auart(s)) {
>  		clk_disable_unprepare(s->clk);
>  		clk_disable_unprepare(s->clk_ahb);
> 


-- 
js
suse labs

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-09 13:56 [PATCH v2] serial: mxs-auart: add missed iounmap() in probe failure and remove Chuhong Yuan
2020-07-14 11:29 ` Jiri Slaby

Linux-Serial Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-serial/0 linux-serial/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-serial linux-serial/ https://lore.kernel.org/linux-serial \
		linux-serial@vger.kernel.org
	public-inbox-index linux-serial

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-serial


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git