From 7ef9498fe0c6bf1fd40bb3dfb691fee76ff13f69 Mon Sep 17 00:00:00 2001 From: Zhao Yakui Date: Wed, 24 Apr 2019 15:36:40 +0800 Subject: [PATCH] acrn/dm: gvt returns negative errno to terminate the initialization When the "i915.enable_gvt=0" is added for SOS kernel boot args, ACRN-DM will fail in course of gvt initialization and errno is returned directly. As the errno defined in linux/errno.h is positive, it will continue the unexpected initialization in ACRN-DM and then the segment fault is triggered. So negative errno is returned in order to terminate the initialization. Tracked-On: #2584 Signed-off-by: Zhao Yakui Reviewed-by: He, Min Acked-by: Yin Fengwei --- devicemodel/hw/pci/gvt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/devicemodel/hw/pci/gvt.c b/devicemodel/hw/pci/gvt.c index 82af03e88..0ce97b66d 100644 --- a/devicemodel/hw/pci/gvt.c +++ b/devicemodel/hw/pci/gvt.c @@ -170,7 +170,7 @@ gvt_create_instance(struct pci_gvt *gvt) gvt->gvt_file = fopen(path, "w"); if (gvt->gvt_file == NULL) { WPRINTF(("GVT: open %s failed\n", path)); - return errno; + return -errno; } DPRINTF(("GVT: %s: domid=%d, low_gm_sz=%dMB, high_gm_sz=%dMB, " @@ -189,10 +189,10 @@ gvt_create_instance(struct pci_gvt *gvt) */ if (fprintf(gvt->gvt_file, "%d,%u,%u,%u\n", guest_domid, gvt_low_gm_sz, gvt_high_gm_sz, gvt_fence_sz) < 0) - ret = errno; + ret = -errno; if (fclose(gvt->gvt_file) != 0) - return errno; + return -errno; if (!ret) gvt->instance_created = 1; @@ -210,17 +210,17 @@ gvt_destroy_instance(struct pci_gvt *gvt) gvt->gvt_file = fopen(path, "w"); if (gvt->gvt_file == NULL) { WPRINTF(("gvt: error: open %s failed", path)); - return errno; + return -errno; } /* -domid means we want the gvt driver to free the gvt instance * of Domain domid. **/ if (fprintf(gvt->gvt_file, "%d\n", -guest_domid) < 0) - ret = errno; + ret = -errno; if (fclose(gvt->gvt_file) != 0) - return errno; + return -errno; if (!ret) gvt->instance_created = 0;