qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] raw: Fix segfault in raw_create when opts is NULL
@ 2014-06-18 23:31 Fam Zheng
  2014-06-19  0:14 ` Eric Blake
  0 siblings, 1 reply; 2+ messages in thread
From: Fam Zheng @ 2014-06-18 23:31 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Chunyan Liu, Stefan Hajnoczi, Milos Vyletel

Reported-by: Milos Vyletel <milos.vyletel@gmail.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
---
 block/raw-posix.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/block/raw-posix.c b/block/raw-posix.c
index dacf4fb..1f45fd8 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -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);
-- 
2.0.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] raw: Fix segfault in raw_create when opts is NULL
  2014-06-18 23:31 [Qemu-devel] [PATCH] raw: Fix segfault in raw_create when opts is NULL Fam Zheng
@ 2014-06-19  0:14 ` Eric Blake
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Blake @ 2014-06-19  0:14 UTC (permalink / raw)
  To: Fam Zheng, qemu-devel
  Cc: Kevin Wolf, Chunyan Liu, Stefan Hajnoczi, Milos Vyletel

[-- Attachment #1: Type: text/plain, Size: 458 bytes --]

On 06/18/2014 05:31 PM, Fam Zheng wrote:
> Reported-by: Milos Vyletel <milos.vyletel@gmail.com>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  block/raw-posix.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 

Chunyan's solution looks better:
https://lists.gnu.org/archive/html/qemu-devel/2014-06/msg04104.html


-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-06-19  0:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-18 23:31 [Qemu-devel] [PATCH] raw: Fix segfault in raw_create when opts is NULL Fam Zheng
2014-06-19  0:14 ` Eric Blake

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).