mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-07 18:05:21 +02:00
PCI: kirin: Fix buffer overflow in kirin_pcie_parse_port()
[ Upstream commitc500a86693
] 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:b22dbbb245
("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>
This commit is contained in:
parent
d08754be99
commit
95248d7497
|
@ -415,12 +415,12 @@ static int kirin_pcie_parse_port(struct kirin_pcie *pcie,
|
|||
if (pcie->gpio_id_reset[i] < 0)
|
||||
continue;
|
||||
|
||||
pcie->num_slots++;
|
||||
if (pcie->num_slots > MAX_PCI_SLOTS) {
|
||||
if (pcie->num_slots + 1 >= MAX_PCI_SLOTS) {
|
||||
dev_err(dev, "Too many PCI slots!\n");
|
||||
ret = -EINVAL;
|
||||
goto put_node;
|
||||
}
|
||||
pcie->num_slots++;
|
||||
|
||||
ret = of_pci_get_devfn(child);
|
||||
if (ret < 0) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user