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@xxxxxxxxxx> --- drivers/tty/serial/8250/8250_men_mcb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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); -- 2.25.1