Skip to content

Commit

Permalink
brcm80211: Don't leak 'vbuffer' in brcmf_sdbrcm_write_vars()
Browse files Browse the repository at this point in the history
If the memory allocation 'nvram_ularray = kmalloc(varsize,
GFP_ATOMIC);' fails we'll leak the memory allocated to 'vbuffer' when
we return -ENOMEM from the function.

This patch resolves the leak by kfree()'ing the allocated memory
before the return.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Acked-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Jesper Juhl authored and John W. Linville committed Jan 10, 2012
1 parent e4922f2 commit c40701e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -3119,8 +3119,10 @@ static int brcmf_sdbrcm_write_vars(struct brcmf_sdio *bus)
/* Verify NVRAM bytes */
brcmf_dbg(INFO, "Compare NVRAM dl & ul; varsize=%d\n", varsize);
nvram_ularray = kmalloc(varsize, GFP_ATOMIC);
if (!nvram_ularray)
if (!nvram_ularray) {
kfree(vbuffer);
return -ENOMEM;
}

/* Upload image to verify downloaded contents. */
memset(nvram_ularray, 0xaa, varsize);
Expand Down

0 comments on commit c40701e

Please sign in to comment.