From fb723efa48103d566eaccff5e71fb034df797fec Mon Sep 17 00:00:00 2001 From: Xinyun Liu Date: Tue, 19 Jun 2018 15:25:20 +0800 Subject: [PATCH] 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 Reviewed-by: Yin Fengwei Acked-by: Anthony Xu --- devicemodel/hw/pci/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devicemodel/hw/pci/core.c b/devicemodel/hw/pci/core.c index 4927a9a84..848d14e36 100644 --- a/devicemodel/hw/pci/core.c +++ b/devicemodel/hw/pci/core.c @@ -821,7 +821,7 @@ static void pci_emul_deinit(struct vmctx *ctx, struct pci_vdev_ops *ops, int bus, int slot, int func, struct funcinfo *fi) { - if (ops->vdev_deinit) + if (ops->vdev_deinit && fi->fi_devi) (*ops->vdev_deinit)(ctx, fi->fi_devi, fi->fi_param); if (fi->fi_param) free(fi->fi_param);