diff mbox series

[-next] 8250_men_mcb: fix error handling in read_uarts_available_from_reg()

Message ID 20230728085723.3195044-1-yangyingliang@huawei.com
State New
Headers show
Series [-next] 8250_men_mcb: fix error handling in read_uarts_available_from_reg() | expand

Commit Message

Yang Yingliang July 28, 2023, 8:57 a.m. UTC
If ioremap() fails, it returns NULL pointer, not ERR_PTR(), fix the
return value check and call release_mem_region() to release resource.

Fixes: c563831ba879 ("8250_men_mcb: Make UART config auto configurable")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/tty/serial/8250/8250_men_mcb.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Jiri Slaby July 31, 2023, 5:37 a.m. UTC | #1
On 28. 07. 23, 10:57, Yang Yingliang wrote:
> If ioremap() fails, it returns NULL pointer, not ERR_PTR(), fix the
> return value check and call release_mem_region() to release resource.
> 
> Fixes: c563831ba879 ("8250_men_mcb: Make UART config auto configurable")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>

Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
diff mbox series

Patch

diff --git a/drivers/tty/serial/8250/8250_men_mcb.c b/drivers/tty/serial/8250/8250_men_mcb.c
index c3143ffddea0..5f301195575d 100644
--- a/drivers/tty/serial/8250/8250_men_mcb.c
+++ b/drivers/tty/serial/8250/8250_men_mcb.c
@@ -94,8 +94,11 @@  static int read_uarts_available_from_register(struct resource *mem_res,
 
 	mem = ioremap(mem_res->start + MEN_Z025_REGISTER_OFFSET,
 		      MEM_UART_REGISTER_SIZE);
-	if (IS_ERR(mem))
+	if (!mem) {
+		release_mem_region(mem_res->start + MEN_Z025_REGISTER_OFFSET,
+				   MEM_UART_REGISTER_SIZE);
 		return -ENOMEM;
+	}
 
 	reg_value = MEN_READ_REGISTER(mem);