Skip to content

Commit

Permalink
staging: brcm80211: fix memory leaks
Browse files Browse the repository at this point in the history
Free resources before exit.

Signed-off-by: Alexander Beregalov <a.beregalov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Alexander Beregalov authored and Greg Kroah-Hartman committed Mar 14, 2011
1 parent ab42abf commit 570edd3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions drivers/staging/brcm80211/brcmfmac/dhd_sdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -5641,6 +5641,10 @@ static int dhdsdio_download_code_array(struct dhd_bus *bus)
unsigned char *ularray;

ularray = kmalloc(bus->ramsize, GFP_ATOMIC);
if (!ularray) {
bcmerror = BCME_NOMEM;
goto err;
}
/* Upload image to verify downloaded contents. */
offset = 0;
memset(ularray, 0xaa, bus->ramsize);
Expand All @@ -5652,7 +5656,7 @@ static int dhdsdio_download_code_array(struct dhd_bus *bus)
DHD_ERROR(("%s: error %d on reading %d membytes"
" at 0x%08x\n",
__func__, bcmerror, MEMBLOCK, offset));
goto err;
goto free;
}

offset += MEMBLOCK;
Expand All @@ -5666,19 +5670,19 @@ static int dhdsdio_download_code_array(struct dhd_bus *bus)
DHD_ERROR(("%s: error %d on reading %d membytes at 0x%08x\n",
__func__, bcmerror,
sizeof(dlarray) - offset, offset));
goto err;
goto free;
}
}

if (memcmp(dlarray, ularray, sizeof(dlarray))) {
DHD_ERROR(("%s: Downloaded image is corrupted.\n",
__func__));
ASSERT(0);
goto err;
goto free;
} else
DHD_ERROR(("%s: Download/Upload/Compare succeeded.\n",
__func__));

free:
kfree(ularray);
}
#endif /* DHD_DEBUG */
Expand Down

0 comments on commit 570edd3

Please sign in to comment.