From: Arvind Yadav Date: Thu, 19 Jan 2017 08:00:44 +0000 (+0530) Subject: tty: serial: 8250: 8250_gsc:- Handle return NULL error from ioremap_nocache X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2cc32b18d1243d65dc312478be08dd5856b44523;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git tty: serial: 8250: 8250_gsc:- Handle return NULL error from ioremap_nocache Here, If ioremap_nocache will fail. It will return NULL. Kernel can run into a NULL-pointer dereference. This error check will avoid NULL pointer dereference. Signed-off-by: Arvind Yadav Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/tty/serial/8250/8250_gsc.c b/drivers/tty/serial/8250/8250_gsc.c index b1e6ae9f1ff9..63306de4390d 100644 --- a/drivers/tty/serial/8250/8250_gsc.c +++ b/drivers/tty/serial/8250/8250_gsc.c @@ -60,6 +60,10 @@ static int __init serial_init_chip(struct parisc_device *dev) 7272727 : 1843200; uart.port.mapbase = address; uart.port.membase = ioremap_nocache(address, 16); + if (!uart.port.membase) { + dev_warn(&dev->dev, "Failed to map memory\n"); + return -ENOMEM; + } uart.port.irq = dev->irq; uart.port.flags = UPF_BOOT_AUTOCONF; uart.port.dev = &dev->dev;