diff options
author | Ke Zhang <m202171830@hust.edu.cn> | 2023-04-28 11:16:36 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-05-30 12:42:10 +0100 |
commit | 3f00df24a5021a6f02c1830a290acd4bceb22a2d (patch) | |
tree | 58fe1754fc366541e30595727d355fdeb46cfb9c /drivers | |
parent | fd3afd7d32dfe98cee910daabc1bc728eb3a95d2 (diff) | |
download | linux-stable-3f00df24a5021a6f02c1830a290acd4bceb22a2d.tar.gz linux-stable-3f00df24a5021a6f02c1830a290acd4bceb22a2d.tar.bz2 linux-stable-3f00df24a5021a6f02c1830a290acd4bceb22a2d.zip |
serial: arc_uart: fix of_iomap leak in `arc_serial_probe`
[ Upstream commit 8ab5fc55d7f65d58a3c3aeadf11bdf60267cd2bd ]
Smatch reports:
drivers/tty/serial/arc_uart.c:631 arc_serial_probe() warn:
'port->membase' from of_iomap() not released on lines: 631.
In arc_serial_probe(), if uart_add_one_port() fails,
port->membase is not released, which would cause a resource leak.
To fix this, I replace of_iomap with devm_platform_ioremap_resource.
Fixes: 8dbe1d5e09a7 ("serial/arc: inline the probe helper")
Signed-off-by: Ke Zhang <m202171830@hust.edu.cn>
Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
Link: https://lore.kernel.org/r/20230428031636.44642-1-m202171830@hust.edu.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/tty/serial/arc_uart.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c index d904a3a345e7..dd4be3c8c049 100644 --- a/drivers/tty/serial/arc_uart.c +++ b/drivers/tty/serial/arc_uart.c @@ -613,10 +613,11 @@ static int arc_serial_probe(struct platform_device *pdev) } uart->baud = val; - port->membase = of_iomap(np, 0); - if (!port->membase) + port->membase = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(port->membase)) { /* No point of dev_err since UART itself is hosed here */ - return -ENXIO; + return PTR_ERR(port->membase); + } port->irq = irq_of_parse_and_map(np, 0); |