* [PATCH] serial: 8250: fix error handling in of_platform_serial_probe()
@ 2017-06-30 22:49 Alexey Khoroshilov
2017-07-18 7:27 ` Greg Kroah-Hartman
0 siblings, 1 reply; 8+ messages in thread
From: Alexey Khoroshilov @ 2017-06-30 22:49 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Arnd Bergmann
Cc: Alexey Khoroshilov, linux-serial, linux-kernel, ldv-project
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>
---
drivers/tty/serial/8250/8250_of.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c
index 1cbadafc6889..f7a0e7831635 100644
--- a/drivers/tty/serial/8250/8250_of.c
+++ b/drivers/tty/serial/8250/8250_of.c
@@ -86,7 +86,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_address;
}
spin_lock_init(&port->lock);
@@ -128,7 +128,7 @@ 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_regio;
}
}
@@ -158,7 +158,10 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
port->handle_irq = fsl8250_handle_irq;
return 0;
-out:
+
+err_regio:
+ irq_dispose_mapping(port->irq);
+err_address:
if (info->clk)
clk_disable_unprepare(info->clk);
return ret;
@@ -192,7 +195,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;
@@ -208,15 +211,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
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] serial: 8250: fix error handling in of_platform_serial_probe()
2017-06-30 22:49 [PATCH] serial: 8250: fix error handling in of_platform_serial_probe() Alexey Khoroshilov
@ 2017-07-18 7:27 ` Greg Kroah-Hartman
2017-07-18 7:33 ` Alexey Khoroshilov
0 siblings, 1 reply; 8+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-18 7:27 UTC (permalink / raw)
To: Alexey Khoroshilov
Cc: Jiri Slaby, Arnd Bergmann, linux-serial, linux-kernel, ldv-project
On Sat, Jul 01, 2017 at 01:49:29AM +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>
> ---
> drivers/tty/serial/8250/8250_of.c | 20 +++++++++++++-------
> 1 file changed, 13 insertions(+), 7 deletions(-)
I've had to drop this from my tree due to the obvious build warning it
adds to the system. Always test-build your patches before sending them
out, it makes maintainers grumpy when you do not do that :(
greg k-h
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] serial: 8250: fix error handling in of_platform_serial_probe()
2017-07-18 7:27 ` Greg Kroah-Hartman
@ 2017-07-18 7:33 ` Alexey Khoroshilov
2017-07-18 11:32 ` [PATCH v2] " Alexey Khoroshilov
0 siblings, 1 reply; 8+ messages in thread
From: Alexey Khoroshilov @ 2017-07-18 7:33 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, Arnd Bergmann, linux-serial, linux-kernel, ldv-project
On 18.07.2017 10:27, Greg Kroah-Hartman wrote:
> On Sat, Jul 01, 2017 at 01:49:29AM +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>
>> ---
>> drivers/tty/serial/8250/8250_of.c | 20 +++++++++++++-------
>> 1 file changed, 13 insertions(+), 7 deletions(-)
>
> I've had to drop this from my tree due to the obvious build warning it
> adds to the system. Always test-build your patches before sending them
> out, it makes maintainers grumpy when you do not do that :(
>
> greg k-h
>
The problem is in conflict with e2860e1f62f2 "serial: 8250_of: Add reset
support" that was not in the Linus tree when the patch was developed.
I will rebase the patch and resend it.
--
Alexey
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2] serial: 8250: fix error handling in of_platform_serial_probe()
2017-07-18 7:33 ` Alexey Khoroshilov
@ 2017-07-18 11:32 ` Alexey Khoroshilov
2017-07-18 15:06 ` Andy Shevchenko
2017-07-18 15:45 ` Johan Hovold
0 siblings, 2 replies; 8+ messages in thread
From: Alexey Khoroshilov @ 2017-07-18 11:32 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Arnd Bergmann
Cc: Alexey Khoroshilov, linux-serial, linux-kernel, ldv-project
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
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2] serial: 8250: fix error handling in of_platform_serial_probe()
2017-07-18 11:32 ` [PATCH v2] " Alexey Khoroshilov
@ 2017-07-18 15:06 ` Andy Shevchenko
2017-07-18 15:45 ` Johan Hovold
1 sibling, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2017-07-18 15:06 UTC (permalink / raw)
To: Alexey Khoroshilov
Cc: Greg Kroah-Hartman, Jiri Slaby, Arnd Bergmann, linux-serial,
linux-kernel, ldv-project
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] serial: 8250: fix error handling in of_platform_serial_probe()
2017-07-18 11:32 ` [PATCH v2] " Alexey Khoroshilov
2017-07-18 15:06 ` Andy Shevchenko
@ 2017-07-18 15:45 ` Johan Hovold
2017-07-18 15:55 ` Andy Shevchenko
2017-07-19 8:32 ` [PATCH v3] " Alexey Khoroshilov
1 sibling, 2 replies; 8+ messages in thread
From: Johan Hovold @ 2017-07-18 15:45 UTC (permalink / raw)
To: Alexey Khoroshilov
Cc: Greg Kroah-Hartman, Jiri Slaby, Arnd Bergmann, linux-serial,
linux-kernel, ldv-project
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] serial: 8250: fix error handling in of_platform_serial_probe()
2017-07-18 15:45 ` Johan Hovold
@ 2017-07-18 15:55 ` Andy Shevchenko
2017-07-19 8:32 ` [PATCH v3] " Alexey Khoroshilov
1 sibling, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2017-07-18 15:55 UTC (permalink / raw)
To: Johan Hovold
Cc: Alexey Khoroshilov, Greg Kroah-Hartman, Jiri Slaby,
Arnd Bergmann, linux-serial, linux-kernel, ldv-project
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v3] serial: 8250: fix error handling in of_platform_serial_probe()
2017-07-18 15:45 ` Johan Hovold
2017-07-18 15:55 ` Andy Shevchenko
@ 2017-07-19 8:32 ` Alexey Khoroshilov
1 sibling, 0 replies; 8+ messages in thread
From: Alexey Khoroshilov @ 2017-07-19 8:32 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Arnd Bergmann
Cc: Alexey Khoroshilov, linux-serial, linux-kernel, ldv-project
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
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-07-19 8:32 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-30 22:49 [PATCH] serial: 8250: fix error handling in of_platform_serial_probe() Alexey Khoroshilov
2017-07-18 7:27 ` Greg Kroah-Hartman
2017-07-18 7:33 ` Alexey Khoroshilov
2017-07-18 11:32 ` [PATCH v2] " Alexey Khoroshilov
2017-07-18 15:06 ` Andy Shevchenko
2017-07-18 15:45 ` Johan Hovold
2017-07-18 15:55 ` Andy Shevchenko
2017-07-19 8:32 ` [PATCH v3] " Alexey Khoroshilov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.