From 4ed6d92226bd9e4ed8364ded9118473868e4781e Mon Sep 17 00:00:00 2001 From: Yonghua Huang Date: Tue, 22 May 2018 19:38:48 +0800 Subject: [PATCH] DM:fix suspicious dereference of pointer in 'pci_emul_deinit() suspicious dereference of pointer 'fi->fi_devi' by passing it to function 'pci_emul_free_bars()' before NULL check. Signed-off-by: Yonghua Huang --- devicemodel/hw/pci/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/devicemodel/hw/pci/core.c b/devicemodel/hw/pci/core.c index 1b7a7606b..3b3287d05 100644 --- a/devicemodel/hw/pci/core.c +++ b/devicemodel/hw/pci/core.c @@ -792,9 +792,10 @@ pci_emul_deinit(struct vmctx *ctx, struct pci_vdev_ops *ops, int bus, int slot, if (fi->fi_param) free(fi->fi_param); - pci_emul_free_bars(fi->fi_devi); - if (fi->fi_devi) + if (fi->fi_devi) { + pci_emul_free_bars(fi->fi_devi); free(fi->fi_devi); + } } void