]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ALSA: asihpi: Fix potential OOB array access
authorTakashi Iwai <tiwai@suse.de>
Thu, 8 Aug 2024 09:14:42 +0000 (11:14 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Oct 2024 10:00:25 +0000 (12:00 +0200)
[ Upstream commit 7b986c7430a6bb68d523dac7bfc74cbd5b44ef96 ]

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>
sound/pci/asihpi/hpimsgx.c

index d0caef2994818efd1fe7162320075400cd94d525..b68e6bfbbfbab51cc46e6c5914518d572cd582de 100644 (file)
@@ -708,7 +708,7 @@ static u16 HPIMSGX__init(struct hpi_message *phm,
                phr->error = HPI_ERROR_PROCESSING_MESSAGE;
                return phr->error;
        }
-       if (hr.error == 0) {
+       if (hr.error == 0 && hr.u.s.adapter_index < HPI_MAX_ADAPTERS) {
                /* the adapter was created successfully
                   save the mapping for future use */
                hpi_entry_points[hr.u.s.adapter_index] = entry_point_func;