* [PATCH v1] tty: serial: 8250: 8250_gsc:- Handle return NULL error from ioremap_nocache
@ 2017-01-19 8:00 Arvind Yadav
2017-01-19 18:48 ` Andy Shevchenko
0 siblings, 1 reply; 2+ messages in thread
From: Arvind Yadav @ 2017-01-19 8:00 UTC (permalink / raw)
To: jejb, deller, gregkh; +Cc: jslaby, linux-parisc, linux-serial, linux-kernel
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 <arvind.yadav.cs@gmail.com>
---
drivers/tty/serial/8250/8250_gsc.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/tty/serial/8250/8250_gsc.c b/drivers/tty/serial/8250/8250_gsc.c
index b1e6ae9..63306de 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;
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v1] tty: serial: 8250: 8250_gsc:- Handle return NULL error from ioremap_nocache
2017-01-19 8:00 [PATCH v1] tty: serial: 8250: 8250_gsc:- Handle return NULL error from ioremap_nocache Arvind Yadav
@ 2017-01-19 18:48 ` Andy Shevchenko
0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2017-01-19 18:48 UTC (permalink / raw)
To: Arvind Yadav
Cc: jejb, Helge Deller, Greg Kroah-Hartman, Jiri Slaby, linux-parisc,
linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org
On Thu, Jan 19, 2017 at 10:00 AM, Arvind Yadav
<arvind.yadav.cs@gmail.com> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-01-19 18:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-19 8:00 [PATCH v1] tty: serial: 8250: 8250_gsc:- Handle return NULL error from ioremap_nocache Arvind Yadav
2017-01-19 18:48 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).