public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Chen Gang <gang.chen@asianux.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Eric Paris <eparis@redhat.com>, Al Viro <viro@zeniv.linux.org.uk>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] kernel/audit_tree.c: tree will memory leak when failure occurs for audit_trim_trees()
Date: Tue, 23 Apr 2013 09:46:50 +0800	[thread overview]
Message-ID: <5175E80A.7030908@asianux.com> (raw)
In-Reply-To: <20130422160409.471f6208099a972d26c29fb9@linux-foundation.org>

On 2013年04月23日 07:04, Andrew Morton wrote:
> On Fri, 19 Apr 2013 17:39:06 +0800 Chen Gang <gang.chen@asianux.com> wrote:
> 
>>
>> in audit_trim_trees(), has called get_tree() before failure occurs,
>> so need also call put_tree after go to skip_it:
>>
>> ...
>>
>> --- a/kernel/audit_tree.c
>> +++ b/kernel/audit_tree.c
>> @@ -617,10 +617,10 @@ void audit_trim_trees(void)
>>  		}
>>  		spin_unlock(&hash_lock);
>>  		trim_marked(tree);
>> -		put_tree(tree);
>>  		drop_collected_mounts(root_mnt);
>>  skip_it:
>>  		mutex_lock(&audit_filter_mutex);
>> +		put_tree(tree);
>>  	}
>>  	list_del(&cursor);
>>  	mutex_unlock(&audit_filter_mutex);
> 
> That looks right to me.
> 
> I think we can micro-optimise the code by performing the put_tree()
> before taking the mutex, to slightly reduce mutex hold times?
> 

  ok, thanks.

> --- a/kernel/audit_tree.c~kernel-audit_treec-tree-will-leak-memory-when-failure-occurs-in-audit_trim_trees-fix
> +++ a/kernel/audit_tree.c
> @@ -619,8 +619,8 @@ void audit_trim_trees(void)
>  		trim_marked(tree);
>  		drop_collected_mounts(root_mnt);
>  skip_it:
> -		mutex_lock(&audit_filter_mutex);
>  		put_tree(tree);
> +		mutex_lock(&audit_filter_mutex);
>  	}
>  	list_del(&cursor);
>  	mutex_unlock(&audit_filter_mutex);
> _
> 
> 
> 
> 


-- 
Chen Gang

Asianux Corporation

  reply	other threads:[~2013-04-23  1:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-19  9:39 [PATCH] kernel/audit_tree.c: tree will memory leak when failure occurs for audit_trim_trees() Chen Gang
2013-04-22 23:04 ` Andrew Morton
2013-04-23  1:46   ` Chen Gang [this message]
2013-05-06  7:41   ` [PATCH kernel-next] kernel/audit_tree.c: fix the original version merging issue for put_tree() Chen Gang
2013-05-09 12:53   ` [PATCH v2] kernel: audit_tree: resource management: need put_tree and goto Err when failure occures Chen Gang
2013-05-09 20:11     ` Andrew Morton
2013-05-10  2:08       ` Chen Gang
2013-05-10  9:50         ` Chen Gang
2013-05-10 11:29           ` Chen Gang
2013-05-13  2:54             ` Chen Gang

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=5175E80A.7030908@asianux.com \
    --to=gang.chen@asianux.com \
    --cc=akpm@linux-foundation.org \
    --cc=eparis@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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