* [PATCH -next] serial: uartlite: Missing uart_unregister_driver() on error in ulite_probe()
@ 2019-11-01 11:19 Mao Wenan
2019-11-01 11:41 ` Johan Hovold
0 siblings, 1 reply; 2+ messages in thread
From: Mao Wenan @ 2019-11-01 11:19 UTC (permalink / raw)
To: jacmet, gregkh, jslaby, shubhrajyoti.datta
Cc: linux-serial, linux-kernel, kernel-janitors, Mao Wenan
If uart_register_driver(&ulite_uart_driver) is success,
but followed function is failed in ulite_probe, it needs to call
uart_unregister_driver to unregister.
Fixes: f33cf776617b ("serial-uartlite: Move the uart register")
Signed-off-by: Mao Wenan <maowenan@huawei.com>
---
drivers/tty/serial/uartlite.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
index 06e79c1..2edae76 100644
--- a/drivers/tty/serial/uartlite.c
+++ b/drivers/tty/serial/uartlite.c
@@ -813,21 +813,29 @@ static int ulite_probe(struct platform_device *pdev)
pdata = devm_kzalloc(&pdev->dev, sizeof(struct uartlite_data),
GFP_KERNEL);
- if (!pdata)
+ if (!pdata) {
+ uart_unregister_driver(&ulite_uart_driver);
return -ENOMEM;
+ }
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res)
+ if (!res) {
+ uart_unregister_driver(&ulite_uart_driver);
return -ENODEV;
+ }
irq = platform_get_irq(pdev, 0);
- if (irq <= 0)
+ if (irq <= 0) {
+ uart_unregister_driver(&ulite_uart_driver);
return -ENXIO;
+ }
pdata->clk = devm_clk_get(&pdev->dev, "s_axi_aclk");
if (IS_ERR(pdata->clk)) {
- if (PTR_ERR(pdata->clk) != -ENOENT)
+ if (PTR_ERR(pdata->clk) != -ENOENT) {
+ uart_unregister_driver(&ulite_uart_driver);
return PTR_ERR(pdata->clk);
+ }
/*
* Clock framework support is optional, continue on
@@ -840,6 +848,7 @@ static int ulite_probe(struct platform_device *pdev)
ret = clk_prepare_enable(pdata->clk);
if (ret) {
dev_err(&pdev->dev, "Failed to prepare clock\n");
+ uart_unregister_driver(&ulite_uart_driver);
return ret;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH -next] serial: uartlite: Missing uart_unregister_driver() on error in ulite_probe()
2019-11-01 11:19 [PATCH -next] serial: uartlite: Missing uart_unregister_driver() on error in ulite_probe() Mao Wenan
@ 2019-11-01 11:41 ` Johan Hovold
0 siblings, 0 replies; 2+ messages in thread
From: Johan Hovold @ 2019-11-01 11:41 UTC (permalink / raw)
To: Mao Wenan
Cc: jacmet, gregkh, jslaby, shubhrajyoti.datta, linux-serial,
linux-kernel, kernel-janitors
On Fri, Nov 01, 2019 at 07:19:50PM +0800, Mao Wenan wrote:
> If uart_register_driver(&ulite_uart_driver) is success,
> but followed function is failed in ulite_probe, it needs to call
> uart_unregister_driver to unregister.
>
> Fixes: f33cf776617b ("serial-uartlite: Move the uart register")
> Signed-off-by: Mao Wenan <maowenan@huawei.com>
No, this is broken. The driver is deregistered at module unload.
That said, f33cf776617b ("serial-uartlite: Move the uart register")
should never have been merged as I have pointed out before:
https://lkml.kernel.org/r/20190523091839.GC568@localhost
I'll see if I can find some time to revisit this and start yelling at
Xilinx people again.
Johan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-11-01 11:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-01 11:19 [PATCH -next] serial: uartlite: Missing uart_unregister_driver() on error in ulite_probe() Mao Wenan
2019-11-01 11:41 ` Johan Hovold
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).