Эх сурвалжийг харах

qcacmn: Add memory corruption check

Do not allocate memory if the ask is larger than the
maximum memory allowed for malloc. We have it limited to 4MB.

CRs-Fixed: 2828104
Change-Id: I5b463dd8eb640c76882653e82e6f6db7cb651cf2
Adwait Nayak 4 жил өмнө
parent
commit
8ca19e58fe

+ 6 - 0
qdf/linux/src/qdf_mem.c

@@ -1780,6 +1780,12 @@ void *qdf_mem_malloc_atomic_fl(size_t size, const char *func, uint32_t line)
 {
 	void *ptr;
 
+	if (!size || size > QDF_MEM_MAX_MALLOC) {
+		qdf_nofl_err("Cannot malloc %zu bytes @ %s:%d", size, func,
+			     line);
+		return NULL;
+	}
+
 	ptr = qdf_mem_prealloc_get(size);
 	if (ptr)
 		return ptr;