From patchwork Wed Jun 18 23:31:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 361773 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 21CD2140086 for ; Thu, 19 Jun 2014 09:32:31 +1000 (EST) Received: from localhost ([::1]:32966 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxPLB-0005sY-CH for incoming@patchwork.ozlabs.org; Wed, 18 Jun 2014 19:32:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36698) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxPKX-00058k-7D for qemu-devel@nongnu.org; Wed, 18 Jun 2014 19:31:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WxPKR-00029d-3E for qemu-devel@nongnu.org; Wed, 18 Jun 2014 19:31:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1091) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxPKQ-00029Y-HR for qemu-devel@nongnu.org; Wed, 18 Jun 2014 19:31:42 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5INVewb028760 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Jun 2014 19:31:40 -0400 Received: from T430.redhat.com (vpn1-114-47.nay.redhat.com [10.66.114.47]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5INVbTl024255; Wed, 18 Jun 2014 19:31:38 -0400 From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 19 Jun 2014 07:31:57 +0800 Message-Id: <1403134317-6817-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Chunyan Liu , Stefan Hajnoczi , Milos Vyletel Subject: [Qemu-devel] [PATCH] raw: Fix segfault in raw_create when opts is NULL X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Reported-by: Milos Vyletel Signed-off-by: Fam Zheng --- 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);