From patchwork Tue Jul 28 15:53:24 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 37826 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n6SFsXcA028296 for ; Tue, 28 Jul 2009 15:54:34 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754604AbZG1Px1 (ORCPT ); Tue, 28 Jul 2009 11:53:27 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754561AbZG1Px1 (ORCPT ); Tue, 28 Jul 2009 11:53:27 -0400 Received: from mgw1.diku.dk ([130.225.96.91]:54744 "EHLO mgw1.diku.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753991AbZG1Px0 (ORCPT ); Tue, 28 Jul 2009 11:53:26 -0400 Received: from localhost (localhost [127.0.0.1]) by mgw1.diku.dk (Postfix) with ESMTP id 3016852C375; Tue, 28 Jul 2009 17:53:26 +0200 (CEST) X-Virus-Scanned: amavisd-new at diku.dk Received: from mgw1.diku.dk ([127.0.0.1]) by localhost (mgw1.diku.dk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lmcT3DFcfTPJ; Tue, 28 Jul 2009 17:53:24 +0200 (CEST) Received: from nhugin.diku.dk (nhugin.diku.dk [130.225.96.140]) by mgw1.diku.dk (Postfix) with ESMTP id D776B52C32D; Tue, 28 Jul 2009 17:53:24 +0200 (CEST) Received: from ask.diku.dk (ask.diku.dk [130.225.96.225]) by nhugin.diku.dk (Postfix) with ESMTP id E386D6DFD0A; Tue, 28 Jul 2009 17:52:39 +0200 (CEST) Received: by ask.diku.dk (Postfix, from userid 3767) id BA8FA154D2F; Tue, 28 Jul 2009 17:53:24 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by ask.diku.dk (Postfix) with ESMTP id B9B431549A9; Tue, 28 Jul 2009 17:53:24 +0200 (CEST) Date: Tue, 28 Jul 2009 17:53:24 +0200 (CEST) From: Julia Lawall To: avi@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH 3/9] virt/kvm: correct error-handling code Message-ID: MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Julia Lawall This code is not executed before file has been initialized to the result of calling eventfd_fget. This function returns an ERR_PTR value in an error case instead of NULL. Thus the test that file is not NULL is always true. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @match exists@ expression x, E; statement S1, S2; @@ x = eventfd_fget(...) ... when != x = E ( * if (x == NULL || ...) S1 else S2 | * if (x == NULL && ...) S1 else S2 ) // Signed-off-by: Julia Lawall --- virt/kvm/eventfd.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c index 99017e8..bb4ebd8 100644 --- a/virt/kvm/eventfd.c +++ b/virt/kvm/eventfd.c @@ -230,7 +230,7 @@ fail: if (eventfd && !IS_ERR(eventfd)) eventfd_ctx_put(eventfd); - if (file && !IS_ERR(file)) + if (!IS_ERR(file)) fput(file); kfree(irqfd);