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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux