From patchwork Mon May 6 22:20:04 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: 241805 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 703982C00F9 for ; Tue, 7 May 2013 08:20:14 +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 1UZTlV-0001N8-2W; Mon, 06 May 2013 22:20:13 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1UZTlN-0001IR-CI for fwts-devel@lists.ubuntu.com; Mon, 06 May 2013 22:20:05 +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 1UZTlN-0003Ez-94 for fwts-devel@lists.ubuntu.com; Mon, 06 May 2013 22:20:05 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH] bios: mtrr: free mtrr_list on file open error Date: Mon, 6 May 2013 23:20:04 +0100 Message-Id: <1367878804-18734-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 Free mtrr_list on file open error to fix resource leak bug. Signed-off-by: Colin Ian King Acked-by: Alex Hung Acked-by: Ivan Hu --- src/bios/mtrr/mtrr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/bios/mtrr/mtrr.c b/src/bios/mtrr/mtrr.c index 284d153..38f89fb 100644 --- a/src/bios/mtrr/mtrr.c +++ b/src/bios/mtrr/mtrr.c @@ -88,8 +88,10 @@ static int get_mtrrs(void) if ((mtrr_list = fwts_list_new()) == NULL) return FWTS_ERROR; - if ((fp = fopen("/proc/mtrr", "r")) == NULL) + if ((fp = fopen("/proc/mtrr", "r")) == NULL) { + fwts_list_free(mtrr_list, free); return FWTS_ERROR; + } while (!feof(fp)) { char *ptr1, *ptr2;