From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YqZ92-0002I9-RI for ltp-list@lists.sourceforge.net; Fri, 08 May 2015 03:40:12 +0000 Received: from [59.151.112.132] (helo=heian.cn.fujitsu.com) by sog-mx-2.v43.ch3.sourceforge.com with esmtp (Exim 4.76) id 1YqZ91-0008QS-1X for ltp-list@lists.sourceforge.net; Fri, 08 May 2015 03:40:12 +0000 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t483cjFg025055 for ; Fri, 8 May 2015 11:38:45 +0800 From: "Wei,Jiangang" Date: Fri, 8 May 2015 11:39:33 +0800 Message-ID: <1431056373-11834-1-git-send-email-weijg.fnst@cn.fujitsu.com> In-Reply-To: <20150507133240.GG28637@rei.suse.de> References: <20150507133240.GG28637@rei.suse.de> MIME-Version: 1.0 Subject: [LTP] [PATCH v2 5/5] kernel/syscalls/fallocate: adjust fclose's position List-Id: Linux Test Project General Discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ltp-list-bounces@lists.sourceforge.net To: ltp-list@lists.sourceforge.net It will encounter resource leak for fp, while fopen succeeds and the pointer para is NULL. so need to move fclose out of if-block. Signed-off-by: Wei,Jiangang --- testcases/kernel/sched/hyperthreading/ht_interrupt/ht_utils.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/testcases/kernel/sched/hyperthreading/ht_interrupt/ht_utils.c b/testcases/kernel/sched/hyperthreading/ht_interrupt/ht_utils.c index 1c33d0c..bd2d373 100644 --- a/testcases/kernel/sched/hyperthreading/ht_interrupt/ht_utils.c +++ b/testcases/kernel/sched/hyperthreading/ht_interrupt/ht_utils.c @@ -30,8 +30,13 @@ int is_cmdline_para(const char *para) return 1; } } - fclose(fp); } + /* If fopen succeeds and the pointer para is NULL, + * It won't enter the above if-block. + * so need to close fp here. + */ + if (fp != NULL) + fclose(fp); return 0; } -- 1.9.3 ------------------------------------------------------------------------------ One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list