Commit ee1ab6f6 authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

vmd: increment dev_cnt once device is initialized



This is done in order to avoid having to decrement this counter in case
of a failure.  Also, it makes the result valid for the few error cases
when we didn't decrement it.

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Ia944fb8b810ce69caa8db5bc7c941e0905c9d3bd
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13954


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarTom Nabarro <tom.nabarro@intel.com>
parent f0441b29
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -967,7 +967,6 @@ vmd_scan_single_bus(struct vmd_pci_bus *bus, struct vmd_pci_device *parent_bridg
			continue;
		}

		dev_cnt++;
		if (new_dev->header->common.header_type & PCI_HEADER_TYPE_BRIDGE) {
			slot_cap.as_uint32_t = 0;
			if (new_dev->pcie_cap != NULL) {
@@ -1009,6 +1008,7 @@ vmd_scan_single_bus(struct vmd_pci_bus *bus, struct vmd_pci_device *parent_bridg
			TAILQ_INSERT_TAIL(&bus->vmd->bus_list, new_bus, tailq);

			vmd_dev_init(new_dev);
			dev_cnt++;

			if (slot_cap.bit_field.hotplug_capable && new_dev->pcie_cap != NULL &&
			    new_dev->pcie_cap->express_cap_register.bit_field.slot_implemented) {
@@ -1025,9 +1025,8 @@ vmd_scan_single_bus(struct vmd_pci_bus *bus, struct vmd_pci_device *parent_bridg
			rc = vmd_init_end_device(new_dev);
			if (rc != 0) {
				vmd_dev_free(new_dev);
				if (dev_cnt) {
					dev_cnt--;
				}
			} else {
				dev_cnt++;
			}
		}
	}