Skip to contentSkip to conversation

ALSA: asihpi: Fix potential OOB array access at reading cache

PATCH New Takashi Iwai 1 participant 1 message May 15 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: asihpi: Fix potential OOB array access at reading cache

find_control() to retrieve a cached info accesses the array with the given index blindly, which may lead to an OOB array access. Add a sanity check for avoiding it.

---
 sound/pci/asihpi/hpicmn.c | 6 ++++++
 1 file changed, 6 insertions(+)
sound/pci/asihpi/hpicmn.c +6 -0
index 0674fd854cc8..5f69c04c672a 100644
@@ -276,6 +276,12 @@ static short find_control(u16 control_index,
 		return 0;
 	}
 
+	if (control_index >= p_cache->control_count) {
+		HPI_DEBUG_LOG(VERBOSE, "control_index out of bounce %d\n",
+			control_index);
+		return 0;
+	}
+
 	*pI = p_cache->p_info[control_index];
 	if (!*pI) {
 		HPI_DEBUG_LOG(VERBOSE, "Uncached Control %d\n",
Signature · 1 line
2.54.0