[lvc-project] [PATCH RFC] PCI: kirin: prevent buffer overflow in kirin_pcie_parse_port
Anastasia Belova
abelova at astralinux.ru
Thu Aug 8 17:45:45 MSK 2024
Just a friendly remainder.
15/07/24 16:49, Anastasia Belova пишет:
> If pcie->num_slots = MAX_PCI_SLOTS, i equals MAX_PCI_SLOTS
> during the next iteration. Then pcie->gpio_id_reset is accessed
> by invalid index. Strengthen check on pcie->num_slots to
> prevent this.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: b22dbbb24571 ("PCI: kirin: Support PERST# GPIOs for HiKey970 external PEX 8606 bridge")
> Signed-off-by: Anastasia Belova <abelova at astralinux.ru>
> ---
> drivers/pci/controller/dwc/pcie-kirin.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c
> index d5523f302102..5ef3384c137d 100644
> --- a/drivers/pci/controller/dwc/pcie-kirin.c
> +++ b/drivers/pci/controller/dwc/pcie-kirin.c
> @@ -413,7 +413,7 @@ static int kirin_pcie_parse_port(struct kirin_pcie *pcie,
> continue;
>
> pcie->num_slots++;
> - if (pcie->num_slots > MAX_PCI_SLOTS) {
> + if (pcie->num_slots >= MAX_PCI_SLOTS) {
> dev_err(dev, "Too many PCI slots!\n");
> ret = -EINVAL;
> goto put_node;
More information about the lvc-project
mailing list