Skip to content

Commit a22ba45

Browse files
committed
OPAL_PCI_SET_POWER_STATE: fix locking in error paths
Otherwise we could exit OPAL holding locks, potentially leading to all sorts of problems later on. Cc: stable # 5.3+ Fixes: 7a3e2c4 Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
1 parent eab215a commit a22ba45

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

core/pci-opal.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -785,31 +785,39 @@ static int64_t opal_pci_set_power_state(uint64_t async_token,
785785
switch (*state) {
786786
case OPAL_PCI_SLOT_POWER_OFF:
787787
if (!slot->ops.prepare_link_change ||
788-
!slot->ops.set_power_state)
788+
!slot->ops.set_power_state) {
789+
phb_unlock(phb);
789790
return OPAL_UNSUPPORTED;
791+
}
790792

791793
slot->async_token = async_token;
792794
slot->ops.prepare_link_change(slot, false);
793795
rc = slot->ops.set_power_state(slot, PCI_SLOT_POWER_OFF);
794796
break;
795797
case OPAL_PCI_SLOT_POWER_ON:
796798
if (!slot->ops.set_power_state ||
797-
!slot->ops.get_link_state)
799+
!slot->ops.get_link_state) {
800+
phb_unlock(phb);
798801
return OPAL_UNSUPPORTED;
802+
}
799803

800804
slot->async_token = async_token;
801805
rc = slot->ops.set_power_state(slot, PCI_SLOT_POWER_ON);
802806
break;
803807
case OPAL_PCI_SLOT_OFFLINE:
804-
if (!pd)
808+
if (!pd) {
809+
phb_unlock(phb);
805810
return OPAL_PARAMETER;
811+
}
806812

807813
pci_remove_bus(phb, &pd->children);
808814
phb_unlock(phb);
809815
return OPAL_SUCCESS;
810816
case OPAL_PCI_SLOT_ONLINE:
811-
if (!pd)
817+
if (!pd) {
818+
phb_unlock(phb);
812819
return OPAL_PARAMETER;
820+
}
813821
pci_scan_bus(phb, pd->secondary_bus, pd->subordinate_bus,
814822
&pd->children, pd, true);
815823
pci_add_device_nodes(phb, &pd->children, pd->dn,

0 commit comments

Comments
 (0)