vmd: fix the memory leak issue if vmd address cannot assigned.
Also cleanup some codes. Change-Id: I45ff18cd2afcf38c50b073e80448ba5e267e3ef7 Signed-off-by: Ziye Yang <ziye.yang@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/472664 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
fcf4c5e426
commit
ccc1c72ca2
@ -73,6 +73,7 @@ static void
|
||||
vmd_align_base_addrs(struct vmd_adapter *vmd, uint32_t alignment)
|
||||
{
|
||||
uint32_t pad;
|
||||
|
||||
/*
|
||||
* Device is not in hot plug path, align the base address remaining from membar 1.
|
||||
*/
|
||||
@ -891,6 +892,7 @@ vmd_scan_single_bus(struct vmd_pci_bus *bus, struct vmd_pci_device *parent_bridg
|
||||
} else {
|
||||
SPDK_DEBUGLOG(SPDK_LOG_VMD, "Removing failed device:%p\n", new_dev);
|
||||
TAILQ_REMOVE(&bus->dev_list, new_dev, tailq);
|
||||
free(new_dev);
|
||||
if (dev_cnt) {
|
||||
dev_cnt--;
|
||||
}
|
||||
@ -1003,12 +1005,13 @@ vmd_scan_pcibus(struct vmd_pci_bus *bus)
|
||||
return dev_cnt;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
vmd_map_bars(struct vmd_adapter *vmd, struct spdk_pci_device *dev)
|
||||
{
|
||||
int rc = spdk_pci_device_map_bar(dev, 0, (void **)&vmd->cfg_vaddr,
|
||||
&vmd->cfgbar, &vmd->cfgbar_size);
|
||||
int rc;
|
||||
|
||||
rc = spdk_pci_device_map_bar(dev, 0, (void **)&vmd->cfg_vaddr,
|
||||
&vmd->cfgbar, &vmd->cfgbar_size);
|
||||
if (rc == 0) {
|
||||
rc = spdk_pci_device_map_bar(dev, 2, (void **)&vmd->mem_vaddr,
|
||||
&vmd->membar, &vmd->membar_size);
|
||||
|
Loading…
Reference in New Issue
Block a user