* [PATCH v2] net: 8390: fix potential NULL pointer dereferences
@ 2019-03-12 7:24 Kangjie Lu
2019-03-12 21:50 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Kangjie Lu @ 2019-03-12 7:24 UTC (permalink / raw)
To: kjlu; +Cc: pakki001, David S. Miller, netdev, linux-kernel
In case ioremap fails, the fix releases resources and returns
to avoid NULL pointer dereferences.
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
drivers/net/ethernet/8390/pcnet_cs.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/net/ethernet/8390/pcnet_cs.c b/drivers/net/ethernet/8390/pcnet_cs.c
index 61e43802b9a5..645efac6310d 100644
--- a/drivers/net/ethernet/8390/pcnet_cs.c
+++ b/drivers/net/ethernet/8390/pcnet_cs.c
@@ -289,6 +289,11 @@ static struct hw_info *get_hwinfo(struct pcmcia_device *link)
virt = ioremap(link->resource[2]->start,
resource_size(link->resource[2]));
+ if (unlikely(!virt)) {
+ pcmcia_release_window(link, link->resource[2]);
+ return NULL;
+ }
+
for (i = 0; i < NR_INFO; i++) {
pcmcia_map_mem_page(link, link->resource[2],
hw_info[i].offset & ~(resource_size(link->resource[2])-1));
@@ -1423,6 +1428,11 @@ static int setup_shmem_window(struct pcmcia_device *link, int start_pg,
/* Try scribbling on the buffer */
info->base = ioremap(link->resource[3]->start,
resource_size(link->resource[3]));
+ if (unlikely(!info->base)) {
+ ret = -ENOMEM;
+ goto failed;
+ }
+
for (i = 0; i < (TX_PAGES<<8); i += 2)
__raw_writew((i>>1), info->base+offset+i);
udelay(100);
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] net: 8390: fix potential NULL pointer dereferences
2019-03-12 7:24 [PATCH v2] net: 8390: fix potential NULL pointer dereferences Kangjie Lu
@ 2019-03-12 21:50 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2019-03-12 21:50 UTC (permalink / raw)
To: kjlu; +Cc: pakki001, netdev, linux-kernel
From: Kangjie Lu <kjlu@umn.edu>
Date: Tue, 12 Mar 2019 02:24:07 -0500
> In case ioremap fails, the fix releases resources and returns
> to avoid NULL pointer dereferences.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] net: 8390: fix potential NULL pointer dereferences
2019-03-11 5:16 Kangjie Lu
@ 2019-03-11 18:50 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2019-03-11 18:50 UTC (permalink / raw)
To: kjlu; +Cc: pakki001, netdev, linux-kernel
From: Kangjie Lu <kjlu@umn.edu>
Date: Mon, 11 Mar 2019 00:16:51 -0500
> In case ioremap fails, the fix returns to avoid NULL pointer
> dereferences.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
> drivers/net/ethernet/8390/pcnet_cs.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/net/ethernet/8390/pcnet_cs.c b/drivers/net/ethernet/8390/pcnet_cs.c
> index 61e43802b9a5..e2b69e214fad 100644
> --- a/drivers/net/ethernet/8390/pcnet_cs.c
> +++ b/drivers/net/ethernet/8390/pcnet_cs.c
> @@ -289,6 +289,9 @@ static struct hw_info *get_hwinfo(struct pcmcia_device *link)
>
> virt = ioremap(link->resource[2]->start,
> resource_size(link->resource[2]));
> + if (unlikely(!virt))
> + return NULL;
> +
You have to release the pcmcia window if you bail here.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] net: 8390: fix potential NULL pointer dereferences
@ 2019-03-11 5:16 Kangjie Lu
2019-03-11 18:50 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Kangjie Lu @ 2019-03-11 5:16 UTC (permalink / raw)
To: kjlu; +Cc: pakki001, David S. Miller, netdev, linux-kernel
In case ioremap fails, the fix returns to avoid NULL pointer
dereferences.
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
drivers/net/ethernet/8390/pcnet_cs.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/ethernet/8390/pcnet_cs.c b/drivers/net/ethernet/8390/pcnet_cs.c
index 61e43802b9a5..e2b69e214fad 100644
--- a/drivers/net/ethernet/8390/pcnet_cs.c
+++ b/drivers/net/ethernet/8390/pcnet_cs.c
@@ -289,6 +289,9 @@ static struct hw_info *get_hwinfo(struct pcmcia_device *link)
virt = ioremap(link->resource[2]->start,
resource_size(link->resource[2]));
+ if (unlikely(!virt))
+ return NULL;
+
for (i = 0; i < NR_INFO; i++) {
pcmcia_map_mem_page(link, link->resource[2],
hw_info[i].offset & ~(resource_size(link->resource[2])-1));
@@ -1423,6 +1426,11 @@ static int setup_shmem_window(struct pcmcia_device *link, int start_pg,
/* Try scribbling on the buffer */
info->base = ioremap(link->resource[3]->start,
resource_size(link->resource[3]));
+ if (unlikely(!info->base)) {
+ ret = -ENOMEM;
+ goto failed;
+ }
+
for (i = 0; i < (TX_PAGES<<8); i += 2)
__raw_writew((i>>1), info->base+offset+i);
udelay(100);
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-03-12 21:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-12 7:24 [PATCH v2] net: 8390: fix potential NULL pointer dereferences Kangjie Lu
2019-03-12 21:50 ` David Miller
-- strict thread matches above, loose matches on Subject: below --
2019-03-11 5:16 Kangjie Lu
2019-03-11 18:50 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.