Skip to content

Commit 7a55740

Browse files
tiwaigregkh
authored andcommitted
ALSA: asihpi: Fix potential OOB array access
[ Upstream commit 7b986c7 ] ASIHPI driver stores some values in the static array upon a response from the driver, and its index depends on the firmware. We shouldn't trust it blindly. This patch adds a sanity check of the array index to fit in the array size. Link: https://patch.msgid.link/20240808091454.30846-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent ddd52c9 commit 7a55740

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sound/pci/asihpi/hpimsgx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ static u16 HPIMSGX__init(struct hpi_message *phm,
708708
phr->error = HPI_ERROR_PROCESSING_MESSAGE;
709709
return phr->error;
710710
}
711-
if (hr.error == 0) {
711+
if (hr.error == 0 && hr.u.s.adapter_index < HPI_MAX_ADAPTERS) {
712712
/* the adapter was created successfully
713713
save the mapping for future use */
714714
hpi_entry_points[hr.u.s.adapter_index] = entry_point_func;

0 commit comments

Comments
 (0)