From patchwork Mon Sep 3 20:40:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Weil X-Patchwork-Id: 1400971 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id ABF833FC85 for ; Mon, 3 Sep 2012 20:47:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753415Ab2ICUrn (ORCPT ); Mon, 3 Sep 2012 16:47:43 -0400 Received: from v220110690675601.yourvserver.net ([78.47.199.172]:50060 "EHLO v220110690675601.yourvserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753214Ab2ICUrn (ORCPT ); Mon, 3 Sep 2012 16:47:43 -0400 X-Greylist: delayed 419 seconds by postgrey-1.27 at vger.kernel.org; Mon, 03 Sep 2012 16:47:42 EDT Received: from localhost (v220110690675601.yourvserver.net.local [127.0.0.1]) by v220110690675601.yourvserver.net (Postfix) with ESMTP id B747B7280029; Mon, 3 Sep 2012 22:40:41 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at weilnetz.de Received: from v220110690675601.yourvserver.net ([127.0.0.1]) by localhost (v220110690675601.yourvserver.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1jq5yCMYVgU7; Mon, 3 Sep 2012 22:40:41 +0200 (CEST) Received: by v220110690675601.yourvserver.net (Postfix, from userid 1000) id 5C976728002B; Mon, 3 Sep 2012 22:40:41 +0200 (CEST) From: Stefan Weil To: qemu-trivial@nongnu.org Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, Stefan Weil Subject: [PATCH] kvm: Fix warning from static code analysis Date: Mon, 3 Sep 2012 22:40:40 +0200 Message-Id: <1346704840-9522-1-git-send-email-sw@weilnetz.de> X-Mailer: git-send-email 1.7.10 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 Reviewed-by: Peter Maydell --- kvm-all.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/kvm-all.c b/kvm-all.c index 34b02c1..20b980d 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1370,13 +1370,11 @@ int kvm_init(void) return 0; err: - if (s) { - if (s->vmfd >= 0) { - close(s->vmfd); - } - if (s->fd != -1) { - close(s->fd); - } + if (s->vmfd >= 0) { + close(s->vmfd); + } + if (s->fd != -1) { + close(s->fd); } g_free(s);