dm: fix possible null pointer dereference in pci_gvt_deinit

will access null pointer if 'gvt' is null.

Tracked-On: #1479
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: He, Min <min.he@intel.com>
This commit is contained in:
Yonghua Huang 2019-04-23 01:13:20 +08:00 committed by wenlingz
parent f991d179b0
commit 3060956582
1 changed files with 13 additions and 11 deletions

View File

@ -262,18 +262,20 @@ pci_gvt_deinit(struct vmctx *ctx, struct pci_vdev *pi, char *opts)
int ret; int ret;
struct pci_gvt *gvt = pi->arg; struct pci_gvt *gvt = pi->arg;
if (gvt && gvt->host_config) { if (gvt) {
/* Free the allocated host_config */ if (gvt->host_config) {
free(gvt->host_config); /* Free the allocated host_config */
gvt->host_config = NULL; free(gvt->host_config);
gvt->host_config = NULL;
}
ret = gvt_destroy_instance(gvt);
if (ret)
WPRINTF(("GVT: %s: failed: errno=%d\n", __func__, ret));
free(gvt);
pi->arg = NULL;
} }
ret = gvt_destroy_instance(gvt);
if (ret)
WPRINTF(("GVT: %s: failed: errno=%d\n", __func__, ret));
free(gvt);
pi->arg = NULL;
} }
struct pci_vdev_ops pci_ops_gvt = { struct pci_vdev_ops pci_ops_gvt = {