summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRajeev Kumar Sirasanagandla <rsirasan@qti.qualcomm.com>2016-05-15 21:41:33 +0530
committerAnjaneedevi Kapparapu <akappa@codeaurora.org>2016-05-18 17:49:07 +0530
commit034b10a04c379c2910931a33dbf63b02e8e3bb89 (patch)
tree90ba532a403bee764ea80e0d7d0c931c538fc8f7
parent231c8ca854dce2404a3a0a91b6a32c358236cc17 (diff)
qcacld-2.0: Add check for bpf set program alloc
During allocation of memory for program field of bpf_set_offload, return value of vos_mem_malloc has to be checked for NULL to avoid NULL pointer exception Change-Id: Ib7a3da08ee73a3ec09e21baf6da08d489649725f CRs-fixed: 1015601
-rw-r--r--CORE/HDD/src/wlan_hdd_cfg80211.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/CORE/HDD/src/wlan_hdd_cfg80211.c b/CORE/HDD/src/wlan_hdd_cfg80211.c
index 1e40d7fe4af7..a1d867b64f1f 100644
--- a/CORE/HDD/src/wlan_hdd_cfg80211.c
+++ b/CORE/HDD/src/wlan_hdd_cfg80211.c
@@ -10058,6 +10058,7 @@ static int hdd_set_reset_bpf_offload(hdd_context_t *hdd_ctx,
struct sir_bpf_set_offload *bpf_set_offload;
eHalStatus hstatus;
int prog_len;
+ int ret_val = -EINVAL;
ENTER();
@@ -10097,6 +10098,11 @@ static int hdd_set_reset_bpf_offload(hdd_context_t *hdd_ctx,
prog_len = nla_len(tb[BPF_PROGRAM]);
bpf_set_offload->program = vos_mem_malloc(sizeof(uint8_t) * prog_len);
+ if (!bpf_set_offload->program) {
+ hddLog(LOGE, FL("failed to allocate memory for bpf filter"));
+ ret_val = -ENOMEM;
+ goto fail;
+ }
bpf_set_offload->current_length = prog_len;
nla_memcpy(bpf_set_offload->program, tb[BPF_PROGRAM], prog_len);
bpf_set_offload->session_id = adapter->sessionId;
@@ -10140,7 +10146,7 @@ fail:
if (bpf_set_offload->current_length)
vos_mem_free(bpf_set_offload->program);
vos_mem_free(bpf_set_offload);
- return -EINVAL;
+ return ret_val;
}
/**