aboutsummaryrefslogtreecommitdiff
path: root/hw/ipmi/pci_ipmi_bt.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2019-12-04 10:36:15 +0100
committerMarkus Armbruster <armbru@redhat.com>2019-12-18 08:36:15 +0100
commitf6166a4da59bdd57b3af8b1c742ce611d6c3d3aa (patch)
treeb3b099cd5fe728caf2223fd965873a51ffa22ade /hw/ipmi/pci_ipmi_bt.c
parentbc0e339b01b330c55532571ae6fce89b0f8a4a96 (diff)
hw/ipmi: Fix realize() error API violations
isa_ipmi_bt_realize(), ipmi_isa_realize(), pci_ipmi_bt_realize(), and pci_ipmi_kcs_realize() dereference @errp when IPMIInterfaceClass method init() fails. That's wrong; see the big comment in error.h. Introduced in commit 0719029c47 "ipmi: Add an ISA KCS low-level interface", then imitated in commit a9b74079cb "ipmi: Add a BT low-level interface" and commit 12f983c6aa "ipmi: Add PCI IPMI interfaces". No caller actually passes null. Fix anyway: splice in a local Error *err, and error_propagate(). Cc: Corey Minyard <cminyard@mvista.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191204093625.14836-9-armbru@redhat.com>
Diffstat (limited to 'hw/ipmi/pci_ipmi_bt.c')
-rw-r--r--hw/ipmi/pci_ipmi_bt.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/hw/ipmi/pci_ipmi_bt.c b/hw/ipmi/pci_ipmi_bt.c
index 6ed925a665..ba9cf016b5 100644
--- a/hw/ipmi/pci_ipmi_bt.c
+++ b/hw/ipmi/pci_ipmi_bt.c
@@ -54,6 +54,7 @@ static void pci_ipmi_lower_irq(IPMIBT *ik)
static void pci_ipmi_bt_realize(PCIDevice *pd, Error **errp)
{
+ Error *err = NULL;
PCIIPMIBTDevice *pik = PCI_IPMI_BT(pd);
IPMIInterface *ii = IPMI_INTERFACE(pd);
IPMIInterfaceClass *iic = IPMI_INTERFACE_GET_CLASS(ii);
@@ -74,8 +75,9 @@ static void pci_ipmi_bt_realize(PCIDevice *pd, Error **errp)
pik->bt.raise_irq = pci_ipmi_raise_irq;
pik->bt.lower_irq = pci_ipmi_lower_irq;
- iic->init(ii, 8, errp);
- if (*errp) {
+ iic->init(ii, 8, &err);
+ if (err) {
+ error_propagate(errp, err);
return;
}
pci_register_bar(pd, 0, PCI_BASE_ADDRESS_SPACE_IO, &pik->bt.io);