Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1690180 > unrolled thread
| Started by | Alexey Khoroshilov <khoroshilov@ispras.ru> |
|---|---|
| First post | 2017-07-18 13:40 +0200 |
| Last post | 2017-07-19 10:40 +0200 |
| Articles | 5 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v2] serial: 8250: fix error handling in of_platform_serial_probe() Alexey Khoroshilov <khoroshilov@ispras.ru> - 2017-07-18 13:40 +0200
Re: [PATCH v2] serial: 8250: fix error handling in of_platform_serial_probe() Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-07-18 17:10 +0200
Re: [PATCH v2] serial: 8250: fix error handling in of_platform_serial_probe() Johan Hovold <johan@kernel.org> - 2017-07-18 17:50 +0200
Re: [PATCH v2] serial: 8250: fix error handling in of_platform_serial_probe() Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-07-18 18:00 +0200
[PATCH v3] serial: 8250: fix error handling in of_platform_serial_probe() Alexey Khoroshilov <khoroshilov@ispras.ru> - 2017-07-19 10:40 +0200
| From | Alexey Khoroshilov <khoroshilov@ispras.ru> |
|---|---|
| Date | 2017-07-18 13:40 +0200 |
| Subject | [PATCH v2] serial: 8250: fix error handling in of_platform_serial_probe() |
| Message-ID | <u4z17-1Qn-17@gated-at.bofh.it> |
clk_disable_unprepare(info->clk) is missed in of_platform_serial_probe(),
while irq_dispose_mapping(port->irq) is missed in of_platform_serial_setup().
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
v2: Rebase on top of e2860e1f62f2 "serial: 8250_of: Add reset support"
drivers/tty/serial/8250/8250_of.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c
index 0cf95fd..539f1a6 100644
--- a/drivers/tty/serial/8250/8250_of.c
+++ b/drivers/tty/serial/8250/8250_of.c
@@ -88,7 +88,7 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
ret = of_address_to_resource(np, 0, &resource);
if (ret) {
dev_warn(&ofdev->dev, "invalid address\n");
- goto out;
+ goto err_unprepare;
}
spin_lock_init(&port->lock);
@@ -130,16 +130,16 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
dev_warn(&ofdev->dev, "unsupported reg-io-width (%d)\n",
prop);
ret = -EINVAL;
- goto out;
+ goto err_dispose;
}
}
info->rst = devm_reset_control_get_optional_shared(&ofdev->dev, NULL);
if (IS_ERR(info->rst))
- goto out;
+ goto err_dispose;
ret = reset_control_deassert(info->rst);
if (ret)
- goto out;
+ goto err_dispose;
port->type = type;
port->uartclk = clk;
@@ -167,7 +167,9 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
port->handle_irq = fsl8250_handle_irq;
return 0;
-out:
+err_dispose:
+ irq_dispose_mapping(port->irq);
+err_unprepare:
if (info->clk)
clk_disable_unprepare(info->clk);
return ret;
@@ -201,7 +203,7 @@ static int of_platform_serial_probe(struct platform_device *ofdev)
memset(&port8250, 0, sizeof(port8250));
ret = of_platform_serial_setup(ofdev, port_type, &port8250.port, info);
if (ret)
- goto out;
+ goto err_setup;
if (port8250.port.fifosize)
port8250.capabilities = UART_CAP_FIFO;
@@ -217,15 +219,18 @@ static int of_platform_serial_probe(struct platform_device *ofdev)
ret = serial8250_register_8250_port(&port8250);
if (ret < 0)
- goto out;
+ goto err_register;
info->type = port_type;
info->line = ret;
platform_set_drvdata(ofdev, info);
return 0;
-out:
- kfree(info);
+err_register:
irq_dispose_mapping(port8250.port.irq);
+ if (info->clk)
+ clk_disable_unprepare(info->clk);
+err_setup:
+ kfree(info);
return ret;
}
--
2.7.4
[toc] | [next] | [standalone]
| From | Andy Shevchenko <andy.shevchenko@gmail.com> |
|---|---|
| Date | 2017-07-18 17:10 +0200 |
| Message-ID | <u4Cil-3Yt-3@gated-at.bofh.it> |
| In reply to | #1690180 |
On Tue, Jul 18, 2017 at 2:32 PM, Alexey Khoroshilov
<khoroshilov@ispras.ru> wrote:
> clk_disable_unprepare(info->clk) is missed in of_platform_serial_probe(),
> while irq_dispose_mapping(port->irq) is missed in of_platform_serial_setup().
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
(I esp. like the part of new label namings)
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> ---
> v2: Rebase on top of e2860e1f62f2 "serial: 8250_of: Add reset support"
>
> drivers/tty/serial/8250/8250_of.c | 23 ++++++++++++++---------
> 1 file changed, 14 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c
> index 0cf95fd..539f1a6 100644
> --- a/drivers/tty/serial/8250/8250_of.c
> +++ b/drivers/tty/serial/8250/8250_of.c
> @@ -88,7 +88,7 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
> ret = of_address_to_resource(np, 0, &resource);
> if (ret) {
> dev_warn(&ofdev->dev, "invalid address\n");
> - goto out;
> + goto err_unprepare;
> }
>
> spin_lock_init(&port->lock);
> @@ -130,16 +130,16 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
> dev_warn(&ofdev->dev, "unsupported reg-io-width (%d)\n",
> prop);
> ret = -EINVAL;
> - goto out;
> + goto err_dispose;
> }
> }
>
> info->rst = devm_reset_control_get_optional_shared(&ofdev->dev, NULL);
> if (IS_ERR(info->rst))
> - goto out;
> + goto err_dispose;
> ret = reset_control_deassert(info->rst);
> if (ret)
> - goto out;
> + goto err_dispose;
>
> port->type = type;
> port->uartclk = clk;
> @@ -167,7 +167,9 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
> port->handle_irq = fsl8250_handle_irq;
>
> return 0;
> -out:
> +err_dispose:
> + irq_dispose_mapping(port->irq);
> +err_unprepare:
> if (info->clk)
> clk_disable_unprepare(info->clk);
> return ret;
> @@ -201,7 +203,7 @@ static int of_platform_serial_probe(struct platform_device *ofdev)
> memset(&port8250, 0, sizeof(port8250));
> ret = of_platform_serial_setup(ofdev, port_type, &port8250.port, info);
> if (ret)
> - goto out;
> + goto err_setup;
>
> if (port8250.port.fifosize)
> port8250.capabilities = UART_CAP_FIFO;
> @@ -217,15 +219,18 @@ static int of_platform_serial_probe(struct platform_device *ofdev)
>
> ret = serial8250_register_8250_port(&port8250);
> if (ret < 0)
> - goto out;
> + goto err_register;
>
> info->type = port_type;
> info->line = ret;
> platform_set_drvdata(ofdev, info);
> return 0;
> -out:
> - kfree(info);
> +err_register:
> irq_dispose_mapping(port8250.port.irq);
> + if (info->clk)
> + clk_disable_unprepare(info->clk);
> +err_setup:
> + kfree(info);
> return ret;
> }
>
> --
> 2.7.4
>
--
With Best Regards,
Andy Shevchenko
[toc] | [prev] | [next] | [standalone]
| From | Johan Hovold <johan@kernel.org> |
|---|---|
| Date | 2017-07-18 17:50 +0200 |
| Subject | Re: [PATCH v2] serial: 8250: fix error handling in of_platform_serial_probe() |
| Message-ID | <u4CV4-4cY-23@gated-at.bofh.it> |
| In reply to | #1690180 |
On Tue, Jul 18, 2017 at 02:32:11PM +0300, Alexey Khoroshilov wrote: > clk_disable_unprepare(info->clk) is missed in of_platform_serial_probe(), > while irq_dispose_mapping(port->irq) is missed in of_platform_serial_setup(). > > Found by Linux Driver Verification project (linuxtesting.org). > > Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru> > @@ -167,7 +167,9 @@ static int of_platform_serial_setup(struct platform_device *ofdev, > port->handle_irq = fsl8250_handle_irq; > > return 0; > -out: > +err_dispose: > + irq_dispose_mapping(port->irq); > +err_unprepare: > if (info->clk) > clk_disable_unprepare(info->clk); > return ret; > @@ -217,15 +219,18 @@ static int of_platform_serial_probe(struct platform_device *ofdev) > > ret = serial8250_register_8250_port(&port8250); > if (ret < 0) > - goto out; > + goto err_register; > > info->type = port_type; > info->line = ret; > platform_set_drvdata(ofdev, info); > return 0; > -out: > - kfree(info); > +err_register: > irq_dispose_mapping(port8250.port.irq); > + if (info->clk) > + clk_disable_unprepare(info->clk); > +err_setup: > + kfree(info); Please name also these error labels after what they do rather than after from where you jump to them (i.e. as you did above in of_platform_serial_setup()). Thanks, Johan
[toc] | [prev] | [next] | [standalone]
| From | Andy Shevchenko <andy.shevchenko@gmail.com> |
|---|---|
| Date | 2017-07-18 18:00 +0200 |
| Message-ID | <u4D4K-4gb-1@gated-at.bofh.it> |
| In reply to | #1690381 |
On Tue, Jul 18, 2017 at 6:45 PM, Johan Hovold <johan@kernel.org> wrote: > On Tue, Jul 18, 2017 at 02:32:11PM +0300, Alexey Khoroshilov wrote: >> clk_disable_unprepare(info->clk) is missed in of_platform_serial_probe(), >> while irq_dispose_mapping(port->irq) is missed in of_platform_serial_setup(). >> +err_register: >> irq_dispose_mapping(port8250.port.irq); >> + if (info->clk) >> + clk_disable_unprepare(info->clk); >> +err_setup: >> + kfree(info); > > Please name also these error labels after what they do rather than after > from where you jump to them (i.e. as you did above in > of_platform_serial_setup()). Actually good point! -- With Best Regards, Andy Shevchenko
[toc] | [prev] | [next] | [standalone]
| From | Alexey Khoroshilov <khoroshilov@ispras.ru> |
|---|---|
| Date | 2017-07-19 10:40 +0200 |
| Subject | [PATCH v3] serial: 8250: fix error handling in of_platform_serial_probe() |
| Message-ID | <u4SGu-5YR-15@gated-at.bofh.it> |
| In reply to | #1690381 |
clk_disable_unprepare(info->clk) is missed in of_platform_serial_probe(),
while irq_dispose_mapping(port->irq) is missed in of_platform_serial_setup().
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
v2: Rebase on top of e2860e1f62f2 "serial: 8250_of: Add reset support"
v3: Rename error labels after what they do as Johan Hovold suggested.
drivers/tty/serial/8250/8250_of.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c
index 0cf95fd..6c5a8ca 100644
--- a/drivers/tty/serial/8250/8250_of.c
+++ b/drivers/tty/serial/8250/8250_of.c
@@ -88,7 +88,7 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
ret = of_address_to_resource(np, 0, &resource);
if (ret) {
dev_warn(&ofdev->dev, "invalid address\n");
- goto out;
+ goto err_unprepare;
}
spin_lock_init(&port->lock);
@@ -130,16 +130,16 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
dev_warn(&ofdev->dev, "unsupported reg-io-width (%d)\n",
prop);
ret = -EINVAL;
- goto out;
+ goto err_dispose;
}
}
info->rst = devm_reset_control_get_optional_shared(&ofdev->dev, NULL);
if (IS_ERR(info->rst))
- goto out;
+ goto err_dispose;
ret = reset_control_deassert(info->rst);
if (ret)
- goto out;
+ goto err_dispose;
port->type = type;
port->uartclk = clk;
@@ -167,7 +167,9 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
port->handle_irq = fsl8250_handle_irq;
return 0;
-out:
+err_dispose:
+ irq_dispose_mapping(port->irq);
+err_unprepare:
if (info->clk)
clk_disable_unprepare(info->clk);
return ret;
@@ -201,7 +203,7 @@ static int of_platform_serial_probe(struct platform_device *ofdev)
memset(&port8250, 0, sizeof(port8250));
ret = of_platform_serial_setup(ofdev, port_type, &port8250.port, info);
if (ret)
- goto out;
+ goto err_free;
if (port8250.port.fifosize)
port8250.capabilities = UART_CAP_FIFO;
@@ -217,15 +219,18 @@ static int of_platform_serial_probe(struct platform_device *ofdev)
ret = serial8250_register_8250_port(&port8250);
if (ret < 0)
- goto out;
+ goto err_dispose;
info->type = port_type;
info->line = ret;
platform_set_drvdata(ofdev, info);
return 0;
-out:
- kfree(info);
+err_dispose:
irq_dispose_mapping(port8250.port.irq);
+ if (info->clk)
+ clk_disable_unprepare(info->clk);
+err_free:
+ kfree(info);
return ret;
}
--
2.7.4
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web