lkml.org 
[lkml]   [2019]   [Nov]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH -next] serial: uartlite: Missing uart_unregister_driver() on error in ulite_probe()
Date
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
\
 
 \ /
  Last update: 2019-11-01 12:21    [W:0.176 / U:0.140 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site