All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: fujitsu: fix a potential NULL pointer dereference
@ 2019-03-11  6:15 Kangjie Lu
  2019-03-11 20:37 ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Kangjie Lu @ 2019-03-11  6:15 UTC (permalink / raw)
  To: kjlu; +Cc: pakki001, David S. Miller, netdev, linux-kernel

In case ioremap fails, the fix returns -ENOMEM to avoid the
NULL pointer dereference.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 drivers/net/ethernet/fujitsu/fmvj18x_cs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/fujitsu/fmvj18x_cs.c b/drivers/net/ethernet/fujitsu/fmvj18x_cs.c
index a69cd19a55ae..5061ddf699a7 100644
--- a/drivers/net/ethernet/fujitsu/fmvj18x_cs.c
+++ b/drivers/net/ethernet/fujitsu/fmvj18x_cs.c
@@ -547,6 +547,9 @@ static int fmvj18x_get_hwinfo(struct pcmcia_device *link, u_char *node_id)
 	return -1;
 
     base = ioremap(link->resource[2]->start, resource_size(link->resource[2]));
+    if (!base)
+	    return -ENOMEM;
+
     pcmcia_map_mem_page(link, link->resource[2], 0);
 
     /*
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: fujitsu: fix a potential NULL pointer dereference
  2019-03-11  6:15 [PATCH] net: fujitsu: fix a potential NULL pointer dereference Kangjie Lu
@ 2019-03-11 20:37 ` David Miller
  2019-03-12  7:16   ` [PATCH v2] " Kangjie Lu
  0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2019-03-11 20:37 UTC (permalink / raw)
  To: kjlu; +Cc: pakki001, netdev, linux-kernel

From: Kangjie Lu <kjlu@umn.edu>
Date: Mon, 11 Mar 2019 01:15:01 -0500

> In case ioremap fails, the fix returns -ENOMEM to avoid the
> NULL pointer dereference.
> 
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
>  drivers/net/ethernet/fujitsu/fmvj18x_cs.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/ethernet/fujitsu/fmvj18x_cs.c b/drivers/net/ethernet/fujitsu/fmvj18x_cs.c
> index a69cd19a55ae..5061ddf699a7 100644
> --- a/drivers/net/ethernet/fujitsu/fmvj18x_cs.c
> +++ b/drivers/net/ethernet/fujitsu/fmvj18x_cs.c
> @@ -547,6 +547,9 @@ static int fmvj18x_get_hwinfo(struct pcmcia_device *link, u_char *node_id)
>  	return -1;
>  
>      base = ioremap(link->resource[2]->start, resource_size(link->resource[2]));
> +    if (!base)
> +	    return -ENOMEM;
> +

You must release the pcmcia window if you exit the function here.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] net: fujitsu: fix a potential NULL pointer dereference
  2019-03-11 20:37 ` David Miller
@ 2019-03-12  7:16   ` Kangjie Lu
  2019-03-12 21:49     ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Kangjie Lu @ 2019-03-12  7:16 UTC (permalink / raw)
  To: kjlu; +Cc: pakki001, David S. Miller, netdev, linux-kernel

In case ioremap fails, the fix releases the pcmcia window and
returns -ENOMEM to avoid the NULL pointer dereference.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 drivers/net/ethernet/fujitsu/fmvj18x_cs.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/ethernet/fujitsu/fmvj18x_cs.c b/drivers/net/ethernet/fujitsu/fmvj18x_cs.c
index a69cd19a55ae..1eca0fdb9933 100644
--- a/drivers/net/ethernet/fujitsu/fmvj18x_cs.c
+++ b/drivers/net/ethernet/fujitsu/fmvj18x_cs.c
@@ -547,6 +547,11 @@ static int fmvj18x_get_hwinfo(struct pcmcia_device *link, u_char *node_id)
 	return -1;
 
     base = ioremap(link->resource[2]->start, resource_size(link->resource[2]));
+    if (!base) {
+	    pcmcia_release_window(link, link->resource[2]);
+	    return -ENOMEM;
+    }
+
     pcmcia_map_mem_page(link, link->resource[2], 0);
 
     /*
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] net: fujitsu: fix a potential NULL pointer dereference
  2019-03-12  7:16   ` [PATCH v2] " Kangjie Lu
@ 2019-03-12 21:49     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2019-03-12 21:49 UTC (permalink / raw)
  To: kjlu; +Cc: pakki001, netdev, linux-kernel

From: Kangjie Lu <kjlu@umn.edu>
Date: Tue, 12 Mar 2019 02:16:21 -0500

> In case ioremap fails, the fix releases the pcmcia window and
> returns -ENOMEM to avoid the NULL pointer dereference.
> 
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>

Applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-03-12 21:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-11  6:15 [PATCH] net: fujitsu: fix a potential NULL pointer dereference Kangjie Lu
2019-03-11 20:37 ` David Miller
2019-03-12  7:16   ` [PATCH v2] " Kangjie Lu
2019-03-12 21:49     ` 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.