linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [PATCH] f2fs: fix wrong return value of f2fs_acl_create
@ 2018-11-19 21:38 Tiezhu Yang
  2018-11-20 12:07 ` Chao Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Tiezhu Yang @ 2018-11-19 21:38 UTC (permalink / raw)
  To: jaegeuk, yuchao0; +Cc: linux-f2fs-devel

When call f2fs_acl_create_masq() failed, the caller f2fs_acl_create()
should return -EIO instead of -ENOMEM, this patch makes it consistent
with posix_acl_create() which has been fixed in commit beaf226b863a
("posix_acl: don't ignore return value of posix_acl_create_masq()").

Fixes: 83dfe53c185e ("f2fs: fix reference leaks in f2fs_acl_create")
Signed-off-by: Tiezhu Yang <kernelpatch@126.com>
---
 fs/f2fs/acl.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
index fa707cd..b791c24 100644
--- a/fs/f2fs/acl.c
+++ b/fs/f2fs/acl.c
@@ -351,13 +351,14 @@ static int f2fs_acl_create(struct inode *dir, umode_t *mode,
 	if (IS_ERR(p))
 		return PTR_ERR(p);
 
+	ret = -ENOMEM;
 	clone = f2fs_acl_clone(p, GFP_NOFS);
 	if (!clone)
-		goto no_mem;
+		goto err_release;
 
 	ret = f2fs_acl_create_masq(clone, mode);
 	if (ret < 0)
-		goto no_mem_clone;
+		goto err_release_clone;
 
 	if (ret == 0)
 		posix_acl_release(clone);
@@ -371,11 +372,11 @@ static int f2fs_acl_create(struct inode *dir, umode_t *mode,
 
 	return 0;
 
-no_mem_clone:
+err_release_clone:
 	posix_acl_release(clone);
-no_mem:
+err_release:
 	posix_acl_release(p);
-	return -ENOMEM;
+	return ret;
 }
 
 int f2fs_init_acl(struct inode *inode, struct inode *dir, struct page *ipage,
-- 
1.8.3.1

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

* Re: [PATCH] f2fs: fix wrong return value of f2fs_acl_create
  2018-11-19 21:38 [PATCH] f2fs: fix wrong return value of f2fs_acl_create Tiezhu Yang
@ 2018-11-20 12:07 ` Chao Yu
  2018-11-20 22:38   ` Tiezhu Yang
  0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2018-11-20 12:07 UTC (permalink / raw)
  To: Tiezhu Yang, jaegeuk, yuchao0; +Cc: linux-f2fs-devel

On 2018-11-20 5:38, Tiezhu Yang wrote:
> When call f2fs_acl_create_masq() failed, the caller f2fs_acl_create()
> should return -EIO instead of -ENOMEM, this patch makes it consistent
> with posix_acl_create() which has been fixed in commit beaf226b863a
> ("posix_acl: don't ignore return value of posix_acl_create_masq()").
> 
> Fixes: 83dfe53c185e ("f2fs: fix reference leaks in f2fs_acl_create")
> Signed-off-by: Tiezhu Yang <kernelpatch@126.com>
> ---
>  fs/f2fs/acl.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
> index fa707cd..b791c24 100644
> --- a/fs/f2fs/acl.c
> +++ b/fs/f2fs/acl.c
> @@ -351,13 +351,14 @@ static int f2fs_acl_create(struct inode *dir, umode_t *mode,
>  	if (IS_ERR(p))
>  		return PTR_ERR(p);
>  
> +	ret = -ENOMEM;
>  	clone = f2fs_acl_clone(p, GFP_NOFS);
>  	if (!clone)

We can avoid assigning ret by:

clone = f2fs_acl_clone(p, GFP_NOFS);
if (!clone) {
	ret = -ENOMEM;
	goto release_acl;
}

> -		goto no_mem;
> +		goto err_release;
>  
>  	ret = f2fs_acl_create_masq(clone, mode);
>  	if (ret < 0)
> -		goto no_mem_clone;
> +		goto err_release_clone;
>  
>  	if (ret == 0)
>  		posix_acl_release(clone);
> @@ -371,11 +372,11 @@ static int f2fs_acl_create(struct inode *dir, umode_t *mode,
>  
>  	return 0;
>  
> -no_mem_clone:
> +err_release_clone:

release_clone:

>  	posix_acl_release(clone);
> -no_mem:
> +err_release:

release_acl:

Tag naming is minor, anyway this patch looks good to me.

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

>  	posix_acl_release(p);
> -	return -ENOMEM;
> +	return ret;
>  }
>  
>  int f2fs_init_acl(struct inode *inode, struct inode *dir, struct page *ipage,
> 

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

* Re: [PATCH] f2fs: fix wrong return value of f2fs_acl_create
  2018-11-20 12:07 ` Chao Yu
@ 2018-11-20 22:38   ` Tiezhu Yang
  0 siblings, 0 replies; 3+ messages in thread
From: Tiezhu Yang @ 2018-11-20 22:38 UTC (permalink / raw)
  To: Chao Yu; +Cc: jaegeuk, linux-f2fs-devel

At 2018-11-20 20:07:55, "Chao Yu" <chao@kernel.org> wrote:
>On 2018-11-20 5:38, Tiezhu Yang wrote:
>> When call f2fs_acl_create_masq() failed, the caller f2fs_acl_create()
>> should return -EIO instead of -ENOMEM, this patch makes it consistent
>> with posix_acl_create() which has been fixed in commit beaf226b863a
>> ("posix_acl: don't ignore return value of posix_acl_create_masq()").
>> 
>> Fixes: 83dfe53c185e ("f2fs: fix reference leaks in f2fs_acl_create")
>> Signed-off-by: Tiezhu Yang <kernelpatch@126.com>
>> ---
>>  fs/f2fs/acl.c | 11 ++++++-----
>>  1 file changed, 6 insertions(+), 5 deletions(-)
>> 
>> diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
>> index fa707cd..b791c24 100644
>> --- a/fs/f2fs/acl.c
>> +++ b/fs/f2fs/acl.c
>> @@ -351,13 +351,14 @@ static int f2fs_acl_create(struct inode *dir, umode_t *mode,
>>  	if (IS_ERR(p))
>>  		return PTR_ERR(p);
>>  
>> +	ret = -ENOMEM;
>>  	clone = f2fs_acl_clone(p, GFP_NOFS);
>>  	if (!clone)
>
>We can avoid assigning ret by:
>
>clone = f2fs_acl_clone(p, GFP_NOFS);
>if (!clone) {
>	ret = -ENOMEM;
>	goto release_acl;
>}
>
>> -		goto no_mem;
>> +		goto err_release;
>>  
>>  	ret = f2fs_acl_create_masq(clone, mode);
>>  	if (ret < 0)
>> -		goto no_mem_clone;
>> +		goto err_release_clone;
>>  
>>  	if (ret == 0)
>>  		posix_acl_release(clone);
>> @@ -371,11 +372,11 @@ static int f2fs_acl_create(struct inode *dir, umode_t *mode,
>>  
>>  	return 0;
>>  
>> -no_mem_clone:
>> +err_release_clone:
>
>release_clone:
>
>>  	posix_acl_release(clone);
>> -no_mem:
>> +err_release:
>
>release_acl:
>
>Tag naming is minor, anyway this patch looks good to me.

Thanks for your suggestion, I will send a v2 patch.

Thanks,

>
>Reviewed-by: Chao Yu <yuchao0@huawei.com>
>
>Thanks,
>
>>  	posix_acl_release(p);
>> -	return -ENOMEM;
>> +	return ret;
>>  }
>>  
>>  int f2fs_init_acl(struct inode *inode, struct inode *dir, struct page *ipage,
>> 

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

end of thread, other threads:[~2018-11-20 22:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-19 21:38 [PATCH] f2fs: fix wrong return value of f2fs_acl_create Tiezhu Yang
2018-11-20 12:07 ` Chao Yu
2018-11-20 22:38   ` Tiezhu Yang

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