diff --git a/core/hdd/src/wlan_hdd_apf.c b/core/hdd/src/wlan_hdd_apf.c index 9e0c42022e7b..723d34d57cf2 100644 --- a/core/hdd/src/wlan_hdd_apf.c +++ b/core/hdd/src/wlan_hdd_apf.c @@ -472,7 +472,8 @@ hdd_apf_read_memory_callback(void *hdd_context, */ pkt_offset = evt->offset - context->offset; - if (context->buf_len < pkt_offset + evt->length) { + if ((pkt_offset > context->buf_len) || + (context->buf_len - pkt_offset < evt->length)) { hdd_err("Read chunk exceeding allocated space"); return; }