]> git.proxmox.com Git - mirror_qemu.git/commitdiff
pr-manager-helper: avoid SIGSEGV when writing to the socket fail
authorPaolo Bonzini <pbonzini@redhat.com>
Tue, 26 Jun 2018 13:39:18 +0000 (15:39 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 28 Jun 2018 17:05:35 +0000 (19:05 +0200)
When writing to the qemu-pr-helper socket failed, the persistent
reservation manager was correctly disconnecting the socket, but it
did not clear pr_mgr->ioc.  So the rest of the code did not know
that the socket had been disconnected, accessed pr_mgr->ioc and
happily caused a crash.

To reproduce, it is enough to stop qemu-pr-helper between QEMU
startup and executing e.g. sg_persist -k /dev/sdb.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
scsi/pr-manager-helper.c

index 82ff6b6123c1904ad05b166fffe2ef7f654ef732..0c0fe389b75c6f40878ee5cbf5827c477cf84607 100644 (file)
@@ -71,6 +71,7 @@ static int pr_manager_helper_write(PRManagerHelper *pr_mgr,
         if (n_written <= 0) {
             assert(n_written != QIO_CHANNEL_ERR_BLOCK);
             object_unref(OBJECT(pr_mgr->ioc));
+            pr_mgr->ioc = NULL;
             return n_written < 0 ? -EINVAL : 0;
         }