From 70d4739ef200760d8cac3355d05b4252f2f37fec Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Wed, 25 Feb 2015 13:08:22 -0500 Subject: [PATCH] qemu-nbd: fork() can fail It is very unlikely, but it is possible. Signed-off-by: Max Reitz Message-Id: <1424887718-10800-10-git-send-email-mreitz@redhat.com> Signed-off-by: Paolo Bonzini --- qemu-nbd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/qemu-nbd.c b/qemu-nbd.c index 0cb0e4e29a..0c9e807a1a 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -635,7 +635,9 @@ int main(int argc, char **argv) * print errors and exit with the proper status code. */ pid = fork(); - if (pid == 0) { + if (pid < 0) { + err(EXIT_FAILURE, "Failed to fork"); + } else if (pid == 0) { close(stderr_fd[0]); ret = qemu_daemon(1, 0);