From 5622cd4fe5ae77a52b68e279d06390d013b2e08c Mon Sep 17 00:00:00 2001
Message-Id: <5622cd4fe5ae77a52b68e279d06390d013b2e08c.1367947969.git.minovotn@redhat.com>
In-Reply-To: <707b9b97153063374d2530e72c49b1499fc21af9.1367947969.git.minovotn@redhat.com>
References: <707b9b97153063374d2530e72c49b1499fc21af9.1367947969.git.minovotn@redhat.com>
From: Laszlo Ersek <lersek@redhat.com>
Date: Mon, 6 May 2013 19:27:30 +0200
Subject: [PATCH 065/114] qemu-ga: Fix null pointer passed to unlink in
 failure branch

RH-Author: Laszlo Ersek <lersek@redhat.com>
Message-id: <1367868499-27603-8-git-send-email-lersek@redhat.com>
Patchwork-id: 51106
O-Subject: [RHEL-6.5 qemu-kvm PATCH v2 07/56] qemu-ga: Fix null pointer passed to unlink in failure branch
Bugzilla: 952873
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>

From: Stefan Weil <sw@weilnetz.de>

Clang reports this warning:

Null pointer passed as an argument to a 'nonnull' parameter

Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 4bdb1a3059d7d3a931de0748a2eec39a0ab41b4e)
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 qemu-ga.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 qemu-ga.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/qemu-ga.c b/qemu-ga.c
index 366f958..73f660c 100644
--- a/qemu-ga.c
+++ b/qemu-ga.c
@@ -438,7 +438,9 @@ static void become_daemon(const char *pidfile)
     return;
 
 fail:
-    unlink(pidfile);
+    if (pidfile) {
+        unlink(pidfile);
+    }
     g_critical("failed to daemonize");
     exit(EXIT_FAILURE);
 #endif
-- 
1.7.11.7

