linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] f2fs: fix reference leaks in f2fs_acl_create
@ 2015-03-09 10:18 Chao Yu
  2015-03-10  1:15 ` Changman Lee
  0 siblings, 1 reply; 2+ messages in thread
From: Chao Yu @ 2015-03-09 10:18 UTC (permalink / raw)
  To: Jaegeuk Kim, Changman Lee; +Cc: linux-f2fs-devel, linux-kernel

Our f2fs_acl_create is copied and modified from posix_acl_create to avoid
deadlock bug when inline_dentry feature is enabled.

Now, we got reference leaks in posix_acl_create, and this has been fixed in
commit fed0b588be2f ("posix_acl: fix reference leaks in posix_acl_create")
by Omar Sandoval.
https://lkml.org/lkml/2015/2/9/5

Let's fix this issue in f2fs_acl_create too.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
---
 fs/f2fs/acl.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
index 7422027..4320ffa 100644
--- a/fs/f2fs/acl.c
+++ b/fs/f2fs/acl.c
@@ -351,13 +351,11 @@ static int f2fs_acl_create(struct inode *dir, umode_t *mode,
 
 	*acl = f2fs_acl_clone(p, GFP_NOFS);
 	if (!*acl)
-		return -ENOMEM;
+		goto no_mem;
 
 	ret = f2fs_acl_create_masq(*acl, mode);
-	if (ret < 0) {
-		posix_acl_release(*acl);
-		return -ENOMEM;
-	}
+	if (ret < 0)
+		goto no_mem_clone;
 
 	if (ret == 0) {
 		posix_acl_release(*acl);
@@ -378,6 +376,12 @@ no_acl:
 	*default_acl = NULL;
 	*acl = NULL;
 	return 0;
+
+no_mem_clone:
+	posix_acl_release(*acl);
+no_mem:
+	posix_acl_release(p);
+	return -ENOMEM;
 }
 
 int f2fs_init_acl(struct inode *inode, struct inode *dir, struct page *ipage,
-- 
2.3.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] f2fs: fix reference leaks in f2fs_acl_create
  2015-03-09 10:18 [PATCH] f2fs: fix reference leaks in f2fs_acl_create Chao Yu
@ 2015-03-10  1:15 ` Changman Lee
  0 siblings, 0 replies; 2+ messages in thread
From: Changman Lee @ 2015-03-10  1:15 UTC (permalink / raw)
  To: Chao Yu; +Cc: Jaegeuk Kim, linux-f2fs-devel, linux-kernel

Reviewed-by: Changman Lee <cm224.lee@ssamsung.com>

On Mon, Mar 09, 2015 at 06:18:19PM +0800, Chao Yu wrote:
> Our f2fs_acl_create is copied and modified from posix_acl_create to avoid
> deadlock bug when inline_dentry feature is enabled.
> 
> Now, we got reference leaks in posix_acl_create, and this has been fixed in
> commit fed0b588be2f ("posix_acl: fix reference leaks in posix_acl_create")
> by Omar Sandoval.
> https://lkml.org/lkml/2015/2/9/5
> 
> Let's fix this issue in f2fs_acl_create too.
> 
> Signed-off-by: Chao Yu <chao2.yu@samsung.com>
> ---
>  fs/f2fs/acl.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
> index 7422027..4320ffa 100644
> --- a/fs/f2fs/acl.c
> +++ b/fs/f2fs/acl.c
> @@ -351,13 +351,11 @@ static int f2fs_acl_create(struct inode *dir, umode_t *mode,
>  
>  	*acl = f2fs_acl_clone(p, GFP_NOFS);
>  	if (!*acl)
> -		return -ENOMEM;
> +		goto no_mem;
>  
>  	ret = f2fs_acl_create_masq(*acl, mode);
> -	if (ret < 0) {
> -		posix_acl_release(*acl);
> -		return -ENOMEM;
> -	}
> +	if (ret < 0)
> +		goto no_mem_clone;
>  
>  	if (ret == 0) {
>  		posix_acl_release(*acl);
> @@ -378,6 +376,12 @@ no_acl:
>  	*default_acl = NULL;
>  	*acl = NULL;
>  	return 0;
> +
> +no_mem_clone:
> +	posix_acl_release(*acl);
> +no_mem:
> +	posix_acl_release(p);
> +	return -ENOMEM;
>  }
>  
>  int f2fs_init_acl(struct inode *inode, struct inode *dir, struct page *ipage,
> -- 
> 2.3.0
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-03-10  1:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-09 10:18 [PATCH] f2fs: fix reference leaks in f2fs_acl_create Chao Yu
2015-03-10  1:15 ` Changman Lee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).