[Libvir] [PATCH] Avoid segfault upon early libvirtd failure.

One of today's leak-plugging patches introduced a bug. Fortunately, it can strike only when libvirtd is about to fail anyway. The consequence is that instead of failing in an orderly manner, it would probably segfault. Sorry about that. Here's the fix: Avoid segfault upon early libvirtd failure. * qemud/qemud.c (main): Don't call qemudCleanup on an uninitialized pointer. By the way, even though this evoked a warning from gcc, "make distcheck" passes. Obviously, that means the distcheck rule is inadequate. I'll fix it so that it turns on -Werror for the final build. Signed-off-by: Jim Meyering <meyering@redhat.com> --- qemud/qemud.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/qemud/qemud.c b/qemud/qemud.c index 96fdf32..b6b82ed 100644 --- a/qemud/qemud.c +++ b/qemud/qemud.c @@ -2025,7 +2025,7 @@ libvirt management daemon:\n\ #define MAX_LISTEN 5 int main(int argc, char **argv) { - struct qemud_server *server; + struct qemud_server *server = NULL; struct sigaction sig_action; int sigpipe[2]; const char *pid_file = NULL; @@ -2180,7 +2180,8 @@ int main(int argc, char **argv) { unlink (pid_file); error1: - qemudCleanup(server); + if (server) + qemudCleanup(server); return ret; } -- 1.5.4.3.366.g55277

On Mon, Mar 03, 2008 at 05:10:28PM +0100, Jim Meyering wrote:
Signed-off-by: Jim Meyering <meyering@redhat.com> --- qemud/qemud.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/qemud/qemud.c b/qemud/qemud.c index 96fdf32..b6b82ed 100644 --- a/qemud/qemud.c +++ b/qemud/qemud.c @@ -2025,7 +2025,7 @@ libvirt management daemon:\n\
#define MAX_LISTEN 5 int main(int argc, char **argv) { - struct qemud_server *server; + struct qemud_server *server = NULL; struct sigaction sig_action; int sigpipe[2]; const char *pid_file = NULL; @@ -2180,7 +2180,8 @@ int main(int argc, char **argv) { unlink (pid_file);
error1: - qemudCleanup(server); + if (server) + qemudCleanup(server); return ret; }
-- 1.5.4.3.366.g55277
+1. And +1 to the other patches you posted today too. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
participants (2)
-
Jim Meyering
-
Richard W.M. Jones