Skip to content

Commit af64919

Browse files
committed
Merge branch 'pci/controller/kirin'
- Fix potential buffer overflow in kirin_pcie_parse_port() (Alexandra Diupina) * pci/controller/kirin: PCI: kirin: Fix buffer overflow in kirin_pcie_parse_port()
2 parents e5f8d1c + c500a86 commit af64919

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/pci/controller/dwc/pcie-kirin.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,11 +420,11 @@ static int kirin_pcie_parse_port(struct kirin_pcie *pcie,
420420
"unable to get a valid reset gpio\n");
421421
}
422422

423-
pcie->num_slots++;
424-
if (pcie->num_slots > MAX_PCI_SLOTS) {
423+
if (pcie->num_slots + 1 >= MAX_PCI_SLOTS) {
425424
dev_err(dev, "Too many PCI slots!\n");
426425
return -EINVAL;
427426
}
427+
pcie->num_slots++;
428428

429429
ret = of_pci_get_devfn(child);
430430
if (ret < 0) {

0 commit comments

Comments
 (0)