Skip to content

Commit

Permalink
net: 8390: fix potential NULL pointer dereferences
Browse files Browse the repository at this point in the history
In case ioremap fails, the fix releases resources and returns
to avoid NULL pointer dereferences.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Kangjie Lu authored and David S. Miller committed Mar 12, 2019
1 parent 9f4d635 commit c7cbc3e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions drivers/net/ethernet/8390/pcnet_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c7cbc3e

Please sign in to comment.