Sfoglia il codice sorgente

qcacmn: Avoid possible out of array access

In function wbuff_buff_put(), there is a possibility to
access array out of boundaries for module slot and pool slot.

Add condition to check for array boundaries.

Change-Id: Iaf5a0ef6b2e712804717abf27d0c0d06862a04f5
CRs-Fixed: 3086342
Dundi Raviteja 3 anni fa
parent
commit
7be08f1577
1 ha cambiato i file con 5 aggiunte e 0 eliminazioni
  1. 5 0
      wbuff/src/wbuff.c

+ 5 - 0
wbuff/src/wbuff.c

@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -345,6 +346,10 @@ qdf_nbuf_t wbuff_buff_put(qdf_nbuf_t buf)
 
 	mslot = (slot_info & WBUFF_MSLOT_BITMASK) >> WBUFF_MSLOT_SHIFT;
 	pslot = (slot_info & WBUFF_PSLOT_BITMASK) >> WBUFF_PSLOT_SHIFT;
+
+	if (mslot >= WBUFF_MAX_MODULES || pslot >= WBUFF_MAX_POOLS)
+		return NULL;
+
 	qdf_nbuf_reset(buffer, wbuff.mod[mslot].reserve, wbuff.mod[mslot].
 		       align);
 	qdf_spin_lock_bh(&wbuff.mod[mslot].lock);