Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1562450 > unrolled thread
| Started by | Arvind Yadav <arvind.yadav.cs@gmail.com> |
|---|---|
| First post | 2017-01-19 09:10 +0100 |
| Last post | 2017-01-19 20:00 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH v1] tty: serial: 8250: 8250_gsc:- Handle return NULL error from ioremap_nocache Arvind Yadav <arvind.yadav.cs@gmail.com> - 2017-01-19 09:10 +0100
Re: [PATCH v1] tty: serial: 8250: 8250_gsc:- Handle return NULL error from ioremap_nocache Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-01-19 20:00 +0100
| From | Arvind Yadav <arvind.yadav.cs@gmail.com> |
|---|---|
| Date | 2017-01-19 09:10 +0100 |
| Subject | [PATCH v1] tty: serial: 8250: 8250_gsc:- Handle return NULL error from ioremap_nocache |
| Message-ID | <t1fXc-7pT-13@gated-at.bofh.it> |
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
[toc] | [next] | [standalone]
| From | Andy Shevchenko <andy.shevchenko@gmail.com> |
|---|---|
| Date | 2017-01-19 20:00 +0100 |
| Subject | Re: [PATCH v1] tty: serial: 8250: 8250_gsc:- Handle return NULL error from ioremap_nocache |
| Message-ID | <t1q6d-5c3-13@gated-at.bofh.it> |
| In reply to | #1562450 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web