[PATCH] net: fujitsu: fix a potential NULL pointer dereference

From: Kangjie Lu
Date: Mon Mar 11 2019 - 02:15:16 EST


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

Signed-off-by: Kangjie Lu <kjlu@xxxxxxx>
---
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