aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Brucker <jean-philippe@linaro.org>2023-06-06 14:04:16 +0100
committerWill Deacon <will@kernel.org>2023-06-08 22:39:03 +0100
commit7bc3b5d7ef8070f91d3139f65030bb3a6aece10f (patch)
tree39f754eeead3f6bc70aef315035060899f899676
parent145a86fedfe8321e857e1370a42b2a24b0bcda2c (diff)
downloadkvmtool-7bc3b5d7ef8070f91d3139f65030bb3a6aece10f.tar.gz
disk/core: Fix segfault on exit with SCSI
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@linaro.org> Link: https://lore.kernel.org/r/20230606130426.978945-8-jean-philippe@linaro.org Signed-off-by: Will Deacon <will@kernel.org>
-rw-r--r--disk/core.c4
1 files 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);