diff options
author | Jesper Juhl <jj@chaosbits.net> | 2012-01-08 17:41:21 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2012-01-10 15:46:40 -0500 |
commit | c40701eacbaebcfe3fb6fac8ef3da653021c212c (patch) | |
tree | 8b602862745a4988a7652b55c50770d0bfc4471c /drivers/net | |
parent | e4922f2b5f1c2b3daa80b56a6eeca984cbee0dde (diff) |
brcm80211: Don't leak 'vbuffer' in brcmf_sdbrcm_write_vars()
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>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 5a002a21f108..f7eeee1dcdb6 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | |||
@@ -3119,8 +3119,10 @@ static int brcmf_sdbrcm_write_vars(struct brcmf_sdio *bus) | |||
3119 | /* Verify NVRAM bytes */ | 3119 | /* Verify NVRAM bytes */ |
3120 | brcmf_dbg(INFO, "Compare NVRAM dl & ul; varsize=%d\n", varsize); | 3120 | brcmf_dbg(INFO, "Compare NVRAM dl & ul; varsize=%d\n", varsize); |
3121 | nvram_ularray = kmalloc(varsize, GFP_ATOMIC); | 3121 | nvram_ularray = kmalloc(varsize, GFP_ATOMIC); |
3122 | if (!nvram_ularray) | 3122 | if (!nvram_ularray) { |
3123 | kfree(vbuffer); | ||
3123 | return -ENOMEM; | 3124 | return -ENOMEM; |
3125 | } | ||
3124 | 3126 | ||
3125 | /* Upload image to verify downloaded contents. */ | 3127 | /* Upload image to verify downloaded contents. */ |
3126 | memset(nvram_ularray, 0xaa, varsize); | 3128 | memset(nvram_ularray, 0xaa, varsize); |