public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: "Wei,Jiangang" <weijg.fnst@cn.fujitsu.com>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH 5/5] kernel/syscalls/fallocate: move fclose out of if-block
Date: Thu, 7 May 2015 15:32:40 +0200	[thread overview]
Message-ID: <20150507133240.GG28637@rei.suse.de> (raw)
In-Reply-To: <1430897176-16486-5-git-send-email-weijg.fnst@cn.fujitsu.com>

Hi!
> It will encounter resource leak for fp as the old flow,
> while fopen succeeds and the pointer para is NULL.
> This patch aims to avoid this resource leak.
> 
> Signed-off-by: Wei,Jiangang <weijg.fnst@cn.fujitsu.com>
> ---
>  testcases/kernel/sched/hyperthreading/ht_interrupt/ht_utils.c | 2 +-
>  1 file changed, 1 insertion(+), 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..c845cf8 100644
> --- a/testcases/kernel/sched/hyperthreading/ht_interrupt/ht_utils.c
> +++ b/testcases/kernel/sched/hyperthreading/ht_interrupt/ht_utils.c
> @@ -30,8 +30,8 @@ int is_cmdline_para(const char *para)

Looking a the code it would be way easier to change it to:

	if (!para)
		return 0;

Then we will need to close the file only inside of the if condition:

	if ((fp = fopen("/proc/cmdline", "r")) != NULL)) {
		...
		fclose(fp);
	}

>  				return 1;
>  			}
>  		}
> -		fclose(fp);
>  	}
> +	if (fp != NULL)	fclose(fp);

This code is not following LKML coding style. You can use checkpath.pl
(distributed with Linux kernel sources) to check you patches before
submission.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
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

  reply	other threads:[~2015-05-07 13:33 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-06  7:26 [LTP] [PATCH 1/5] kernel/syscalls/mmap: remove unused cleanup() Wei,Jiangang
2015-05-06  7:26 ` [LTP] [PATCH 2/5] kernel/syscalls/ipc/lib: Don't allocate memory for getpwnam() Wei,Jiangang
2015-05-07 13:21   ` Cyril Hrubis
2015-05-08  3:28     ` [LTP] [PATCH v2 " Wei,Jiangang
2015-05-06  7:26 ` [LTP] [PATCH 3/5] kernel/mem/hugetlb/lib: " Wei,Jiangang
2015-05-07 13:21   ` Cyril Hrubis
2015-05-08  3:31     ` [LTP] [PATCH v2 " Wei,Jiangang
2015-05-08  8:33     ` [LTP] [PATCH v3 3/5] kernel/mem/hugetlb/lib: do refactor for getuserid Wei,Jiangang
2015-05-06  7:26 ` [LTP] [PATCH 4/5] kernel/syscalls/dup2: free fildes to avoid memory leak Wei,Jiangang
2015-05-07 13:26   ` Cyril Hrubis
2015-05-08  3:33     ` [LTP] [PATCH v2 4/5] kernel/syscalls/dup2: optimize allocation and free Wei,Jiangang
2015-05-06  7:26 ` [LTP] [PATCH 5/5] kernel/syscalls/fallocate: move fclose out of if-block Wei,Jiangang
2015-05-07 13:32   ` Cyril Hrubis [this message]
2015-05-08  3:39     ` [LTP] [PATCH v2 5/5] kernel/syscalls/fallocate: adjust fclose's position Wei,Jiangang
2015-05-07 13:22 ` [LTP] [PATCH 1/5] kernel/syscalls/mmap: remove unused cleanup() Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150507133240.GG28637@rei.suse.de \
    --to=chrubis@suse.cz \
    --cc=ltp-list@lists.sourceforge.net \
    --cc=weijg.fnst@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox