Skip to content

Commit fb723ef

Browse files
xinyunliulijinxia
authored andcommitted
dm: check pci_vdev before using
acrn-dm runs to segmentation fault when failed to create VMs with improper parameters. If vdevs failed to be created, they are still be freed in deinit(), and dereference the null pointers leads to segfault. Signed-off-by: Xinyun Liu <xinyun.liu@intel.com> Reviewed-by: Yin Fengwei <fengwei.yin@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
1 parent 685d82c commit fb723ef

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

devicemodel/hw/pci/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ static void
821821
pci_emul_deinit(struct vmctx *ctx, struct pci_vdev_ops *ops, int bus, int slot,
822822
int func, struct funcinfo *fi)
823823
{
824-
if (ops->vdev_deinit)
824+
if (ops->vdev_deinit && fi->fi_devi)
825825
(*ops->vdev_deinit)(ctx, fi->fi_devi, fi->fi_param);
826826
if (fi->fi_param)
827827
free(fi->fi_param);

0 commit comments

Comments
 (0)