From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52513) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLuuE-0003sw-AK for qemu-devel@nongnu.org; Fri, 07 Mar 2014 08:33:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WLuu9-0001uc-BJ for qemu-devel@nongnu.org; Fri, 07 Mar 2014 08:33:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:5882) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLuu9-0001sc-2B for qemu-devel@nongnu.org; Fri, 07 Mar 2014 08:33:37 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s27DXaO8016374 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 7 Mar 2014 08:33:36 -0500 From: Kevin Wolf Date: Fri, 7 Mar 2014 14:33:03 +0100 Message-Id: <1394199187-9576-16-git-send-email-kwolf@redhat.com> In-Reply-To: <1394199187-9576-1-git-send-email-kwolf@redhat.com> References: <1394199187-9576-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 15/19] blockdev: Fix NULL pointer dereference in blockdev-add List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com If aio=native, we check that cache.direct is set as well. If however cache wasn't specified at all, qemu just segfaulted. The old condition didn't make any sense anyway because it effectively only checked for the default cache mode case, but not for an explicitly set cache.direct=off mode. Signed-off-by: Kevin Wolf Reviewed-by: Benoit Canet Reviewed-by: Eric Blake --- blockdev.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/blockdev.c b/blockdev.c index 561cb81..c3422a1 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2283,8 +2283,10 @@ void qmp_blockdev_add(BlockdevOptions *options, Error **errp) * * For now, simply forbidding the combination for all drivers will do. */ if (options->has_aio && options->aio == BLOCKDEV_AIO_OPTIONS_NATIVE) { - bool direct = options->cache->has_direct && options->cache->direct; - if (!options->has_cache && !direct) { + bool direct = options->has_cache && + options->cache->has_direct && + options->cache->direct; + if (!direct) { error_setg(errp, "aio=native requires cache.direct=true"); goto fail; } -- 1.8.1.4