From patchwork Mon May 6 22:06:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 241802 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 037632C00D8 for ; Tue, 7 May 2013 08:07:03 +1000 (EST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1UZTYj-000863-Tn; Mon, 06 May 2013 22:07:01 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1UZTYe-00080N-Jn for fwts-devel@lists.ubuntu.com; Mon, 06 May 2013 22:06:56 +0000 Received: from cpc3-craw6-2-0-cust180.croy.cable.virginmedia.com ([77.100.248.181] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1UZTYe-0002kr-E3 for fwts-devel@lists.ubuntu.com; Mon, 06 May 2013 22:06:56 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH] hotkey: close fd on error Date: Mon, 6 May 2013 23:06:55 +0100 Message-Id: <1367878015-18122-1-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 1.8.1.2 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: fwts-devel-bounces@lists.ubuntu.com From: Colin Ian King Coverity CID #997348, Resource leak. Need to close fd before we return. Signed-off-by: Colin Ian King Acked-by: Alex Hung Acked-by: Ivan Hu --- src/hotkey/hotkey/hotkey.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hotkey/hotkey/hotkey.c b/src/hotkey/hotkey/hotkey.c index 38be7b0..ff3c669 100644 --- a/src/hotkey/hotkey/hotkey.c +++ b/src/hotkey/hotkey/hotkey.c @@ -84,6 +84,7 @@ static int hotkey_test(fwts_framework *fw, char *dev, fwts_list *hotkeys) if (ioctl(fd, EVIOCGRAB, (void*)1)) { /* Get focus */ fwts_log_error(fw, "Cannot grab device %s.", path); + close(fd); return FWTS_ERROR; } @@ -106,6 +107,7 @@ static int hotkey_test(fwts_framework *fw, char *dev, fwts_list *hotkeys) if (ioctl(fd, EVIOCGRAB, (void*)0)) { /* Release */ fwts_log_error(fw, "Cannot un-grab device %s.", path); + close(fd); return FWTS_ERROR; } close(fd);