Skip to contentSkip to conversation

raw: Fix segfault in raw_create when opts is NULL

PATCH In review Fam Zheng 2 participants 2 messages Jun 18, 2014 – Jun 19, 2014 Block layer

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

PATCH 1/1 raw: Fix segfault in raw_create when opts is NULL

---
 block/raw-posix.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
block/raw-posix.c +4 -2
index dacf4fb..1f45fd8 100644
@@ -1282,8 +1282,10 @@ static int raw_create(const char *filename, QemuOpts *opts, Error **errp)
     strstart(filename, "file:", &filename);
 
     /* Read out options */
-    total_size =
-        qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0) / BDRV_SECTOR_SIZE;
+    if (opts) {
+        total_size =
+            qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0) / BDRV_SECTOR_SIZE;
+    }
 
     fd = qemu_open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
                    0644);
Signature · 1 line
2.0.0