From e9bf3814f4252e5d2f37c83ddf17b99c24b1ecf1 Mon Sep 17 00:00:00 2001 From: OBattler Date: Thu, 5 Oct 2023 00:55:25 +0200 Subject: [PATCH] Added a clobbering-mitigating mechanism to pci_relocate_slot(), fixes PCI graphics cards on PC Chips ALi ALADDiN V and Pro II machines. --- src/pci.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pci.c b/src/pci.c index 61de21857..6c0a904bb 100644 --- a/src/pci.c +++ b/src/pci.c @@ -240,7 +240,6 @@ pci_relocate_slot(int type, int new_slot) { int card = -1; int old_slot; - uint8_t mapping; if ((new_slot < 0) || (new_slot > 31)) return; @@ -257,9 +256,12 @@ pci_relocate_slot(int type, int new_slot) old_slot = pci_cards[card].id; pci_cards[card].id = new_slot; - mapping = pci_card_to_slot_mapping[0][old_slot]; - pci_card_to_slot_mapping[0][old_slot] = PCI_CARD_INVALID; - pci_card_to_slot_mapping[0][new_slot] = mapping; + + if (pci_card_to_slot_mapping[0][old_slot] == card) + pci_card_to_slot_mapping[0][old_slot] = PCI_CARD_INVALID; + + if (pci_card_to_slot_mapping[0][new_slot] == PCI_CARD_INVALID) + pci_card_to_slot_mapping[0][new_slot] = card; } /* Write PCI enable/disable key, split for the ALi M1435. */