[PATCH kvmtool v2 07/17] disk/core: Fix segfault on exit with SCSI

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The SCSI backend doesn't call disk_image__new() so the disk ops are
NULL. Check for this case on exit.

Signed-off-by: Jean-Philippe Brucker <jean-philippe@xxxxxxxxxx>
---
 disk/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/disk/core.c b/disk/core.c
index 652fcd1a..b00b0c0a 100644
--- a/disk/core.c
+++ b/disk/core.c
@@ -223,10 +223,10 @@ static int disk_image__close(struct disk_image *disk)
 
 	disk_aio_destroy(disk);
 
-	if (disk->ops->close)
+	if (disk->ops && disk->ops->close)
 		return disk->ops->close(disk);
 
-	if (close(disk->fd) < 0)
+	if (disk->fd && close(disk->fd) < 0)
 		pr_warning("close() failed");
 
 	free(disk);
-- 
2.40.1




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux