From 564984570cc8bd5b719eac2ef2bc89ebb934f13e Mon Sep 17 00:00:00 2001 From: Minggui Cao Date: Wed, 20 May 2020 11:12:38 +0800 Subject: [PATCH] HV: explicitly init lock variable before using it 1. though "pci_device_lock" & "logmsg_ctl.lock" are set to 0 when system dose memory initialization, it is better to explicitly init them before using. 2. unify the usage of spinlock_init Tracked-On: #4827 Signed-off-by: Minggui Cao Acked-by: Eddie Dong --- hypervisor/debug/logmsg.c | 2 ++ hypervisor/hw/pci.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/hypervisor/debug/logmsg.c b/hypervisor/debug/logmsg.c index 9e374b1e8..31d2d41f9 100644 --- a/hypervisor/debug/logmsg.c +++ b/hypervisor/debug/logmsg.c @@ -29,6 +29,8 @@ void init_logmsg(uint32_t flags) { logmsg_ctl.flags = flags; logmsg_ctl.seq = 0; + + spinlock_init(&(logmsg_ctl.lock)); } void do_logmsg(uint32_t severity, const char *fmt, ...) diff --git a/hypervisor/hw/pci.c b/hypervisor/hw/pci.c index a323f907f..f6a004ee8 100644 --- a/hypervisor/hw/pci.c +++ b/hypervisor/hw/pci.c @@ -610,6 +610,9 @@ void init_pci_pdev_list(void) uint16_t bus; bool was_visited = false; + /* explicitly init the lock before using it */ + spinlock_init(&pci_device_lock); + pci_parse_iommu_devscopes(&bdfs_from_drhds, &drhd_idx_pci_all); /* TODO: iterate over list of PCI Host Bridges found in ACPI namespace */