Skip to content

Commit 8ab5fc5

Browse files
souikkgregkh
authored andcommitted
serial: arc_uart: fix of_iomap leak in arc_serial_probe
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: 8dbe1d5 ("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>
1 parent f16182e commit 8ab5fc5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/tty/serial/arc_uart.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -606,10 +606,11 @@ static int arc_serial_probe(struct platform_device *pdev)
606606
}
607607
uart->baud = val;
608608

609-
port->membase = of_iomap(np, 0);
610-
if (!port->membase)
609+
port->membase = devm_platform_ioremap_resource(pdev, 0);
610+
if (IS_ERR(port->membase)) {
611611
/* No point of dev_err since UART itself is hosed here */
612-
return -ENXIO;
612+
return PTR_ERR(port->membase);
613+
}
613614

614615
port->irq = irq_of_parse_and_map(np, 0);
615616

0 commit comments

Comments
 (0)