Re: [PATCH v1] tty: serial: 8250: 8250_gsc:- Handle return NULL error from ioremap_nocache

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

 



On Thu, Jan 19, 2017 at 10:00 AM, Arvind Yadav
<arvind.yadav.cs@xxxxxxxxx> wrote:
> 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.

>         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;
> +       }

You also may do something like

void __iomem *base;
...

base = ioremap_nocache(...);
if (!base)
 return -ENOMEM;
// I doubt the message is useful, up to you

memset(&uart, 0, sizeof(uart));
...
uart.port.membase       = base;

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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