kvm: Fix warning from static code analysis

Report from smatch:

kvm-all.c:1373 kvm_init(135) warn:
 variable dereferenced before check 's' (see line 1360)

's' cannot by NULL (it was alloced using g_malloc0), so there is no need
to check it here.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
(cherry picked from commit 6d1cc3210c)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
This commit is contained in:
Stefan Weil 2012-09-03 22:40:40 +02:00 committed by Michael Roth
parent 59a01f73c3
commit a78cedc09e
1 changed files with 5 additions and 7 deletions

View File

@ -1374,14 +1374,12 @@ int kvm_init(void)
return 0; return 0;
err: err:
if (s) {
if (s->vmfd >= 0) { if (s->vmfd >= 0) {
close(s->vmfd); close(s->vmfd);
} }
if (s->fd != -1) { if (s->fd != -1) {
close(s->fd); close(s->fd);
} }
}
g_free(s); g_free(s);
return ret; return ret;