yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-blockdev-Fix-NULL-pointer-dereference-in-blockdev-ad.patch

9ae3a8
From 55355b00b588e875583e2463beac3d5d1b53ac35 Mon Sep 17 00:00:00 2001
9ae3a8
From: Kevin Wolf <kwolf@redhat.com>
9ae3a8
Date: Thu, 23 Oct 2014 10:10:07 +0200
9ae3a8
Subject: [PATCH 04/19] blockdev: Fix NULL pointer dereference in blockdev-add
9ae3a8
9ae3a8
Message-id: <1414059011-15516-5-git-send-email-kwolf@redhat.com>
9ae3a8
Patchwork-id: 61838
9ae3a8
O-Subject: [RHEL-7.1 qemu-kvm PATCH v2 4/8] blockdev: Fix NULL pointer dereference in blockdev-add
9ae3a8
Bugzilla: 1088176
9ae3a8
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
9ae3a8
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
9ae3a8
RH-Acked-by: Max Reitz <mreitz@redhat.com>
9ae3a8
9ae3a8
If aio=native, we check that cache.direct is set as well. If however
9ae3a8
cache wasn't specified at all, qemu just segfaulted.
9ae3a8
9ae3a8
The old condition didn't make any sense anyway because it effectively
9ae3a8
only checked for the default cache mode case, but not for an explicitly
9ae3a8
set cache.direct=off mode.
9ae3a8
9ae3a8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
Reviewed-by: Benoit Canet <benoit@irqsave.net>
9ae3a8
Reviewed-by: Eric Blake <eblake@redhat.com>
9ae3a8
(cherry picked from commit c6e0bd9b7037937aafeb1d34ec17975a7d685bb7)
9ae3a8
9ae3a8
Trivial bonus bugfix so that the backported test 087 won't fail.
9ae3a8
9ae3a8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 blockdev.c | 6 ++++--
9ae3a8
 1 file changed, 4 insertions(+), 2 deletions(-)
9ae3a8
9ae3a8
diff --git a/blockdev.c b/blockdev.c
9ae3a8
index a2d5f02..1ac8804 100644
9ae3a8
--- a/blockdev.c
9ae3a8
+++ b/blockdev.c
9ae3a8
@@ -1810,8 +1810,10 @@ void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
9ae3a8
      *
9ae3a8
      * For now, simply forbidding the combination for all drivers will do. */
9ae3a8
     if (options->has_aio && options->aio == BLOCKDEV_AIO_OPTIONS_NATIVE) {
9ae3a8
-        bool direct = options->cache->has_direct && options->cache->direct;
9ae3a8
-        if (!options->has_cache && !direct) {
9ae3a8
+        bool direct = options->has_cache &&
9ae3a8
+                      options->cache->has_direct &&
9ae3a8
+                      options->cache->direct;
9ae3a8
+        if (!direct) {
9ae3a8
             error_setg(errp, "aio=native requires cache.direct=true");
9ae3a8
             goto fail;
9ae3a8
         }
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8