]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
PCI: kirin: Fix buffer overflow in kirin_pcie_parse_port()
authorAlexandra Diupina <adiupina@astralinux.ru>
Tue, 3 Sep 2024 11:58:23 +0000 (14:58 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 4 Oct 2024 14:29:32 +0000 (16:29 +0200)
commit95248d7497bcbfe7deed4805469c6ff6ddd7f9d1
tree1af0fabd3f6b64bad953217b07cb18e5db4750d9
parentd08754be993f270e3d296d8f5d8e071fe6638651
PCI: kirin: Fix buffer overflow in kirin_pcie_parse_port()

[ Upstream commit c500a86693a126c9393e602741e348f80f1b0fc5 ]

Within kirin_pcie_parse_port(), the pcie->num_slots is compared to
pcie->gpio_id_reset size (MAX_PCI_SLOTS) which is correct and would lead
to an overflow.

Thus, fix condition to pcie->num_slots + 1 >= MAX_PCI_SLOTS and move
pcie->num_slots increment below the if-statement to avoid out-of-bounds
array access.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: b22dbbb24571 ("PCI: kirin: Support PERST# GPIOs for HiKey970 external PEX 8606 bridge")
Link: https://lore.kernel.org/linux-pci/20240903115823.30647-1-adiupina@astralinux.ru
Signed-off-by: Alexandra Diupina <adiupina@astralinux.ru>
[kwilczynski: commit log]
Signed-off-by: Krzysztof WilczyƄski <kwilczynski@kernel.org>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/pci/controller/dwc/pcie-kirin.c