All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: donot need to check return value of xlog_kvmalloc()
@ 2022-08-22 11:46 Zhiqiang Liu
  2022-08-27  3:11 ` Zhiqiang Liu
  2022-08-29 16:06 ` Eric Sandeen
  0 siblings, 2 replies; 4+ messages in thread
From: Zhiqiang Liu @ 2022-08-22 11:46 UTC (permalink / raw)
  To: Darrick J. Wong, linux-xfs, linux-kernel
  Cc: linfeilong, wuguanghao, liuzhiqiang26


In xfs_attri_log_nameval_alloc(), xlog_kvmalloc() is called
to alloc memory, which will always return
successfully, so we donot need to check return value.

Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
---
 fs/xfs/xfs_attr_item.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c
index 5077a7ad5646..667e151a2bca 100644
--- a/fs/xfs/xfs_attr_item.c
+++ b/fs/xfs/xfs_attr_item.c
@@ -86,8 +86,6 @@ xfs_attri_log_nameval_alloc(
 	 */
 	nv = xlog_kvmalloc(sizeof(struct xfs_attri_log_nameval) +
 					name_len + value_len);
-	if (!nv)
-		return nv;

 	nv->name.i_addr = nv + 1;
 	nv->name.i_len = name_len;
-- 
2.33.0



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

* Re: [PATCH] xfs: donot need to check return value of xlog_kvmalloc()
  2022-08-22 11:46 [PATCH] xfs: donot need to check return value of xlog_kvmalloc() Zhiqiang Liu
@ 2022-08-27  3:11 ` Zhiqiang Liu
  2022-08-29 16:06 ` Eric Sandeen
  1 sibling, 0 replies; 4+ messages in thread
From: Zhiqiang Liu @ 2022-08-27  3:11 UTC (permalink / raw)
  To: Darrick J. Wong, linux-xfs, linux-kernel; +Cc: linfeilong, wuguanghao

friendly ping..

On 2022/8/22 19:46, Zhiqiang Liu wrote:
> In xfs_attri_log_nameval_alloc(), xlog_kvmalloc() is called
> to alloc memory, which will always return
> successfully, so we donot need to check return value.
>
> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
> ---
>  fs/xfs/xfs_attr_item.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c
> index 5077a7ad5646..667e151a2bca 100644
> --- a/fs/xfs/xfs_attr_item.c
> +++ b/fs/xfs/xfs_attr_item.c
> @@ -86,8 +86,6 @@ xfs_attri_log_nameval_alloc(
>  	 */
>  	nv = xlog_kvmalloc(sizeof(struct xfs_attri_log_nameval) +
>  					name_len + value_len);
> -	if (!nv)
> -		return nv;
>
>  	nv->name.i_addr = nv + 1;
>  	nv->name.i_len = name_len;


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

* Re: [PATCH] xfs: donot need to check return value of xlog_kvmalloc()
  2022-08-22 11:46 [PATCH] xfs: donot need to check return value of xlog_kvmalloc() Zhiqiang Liu
  2022-08-27  3:11 ` Zhiqiang Liu
@ 2022-08-29 16:06 ` Eric Sandeen
  2022-08-31  9:48   ` Zhiqiang Liu
  1 sibling, 1 reply; 4+ messages in thread
From: Eric Sandeen @ 2022-08-29 16:06 UTC (permalink / raw)
  To: Zhiqiang Liu, Darrick J. Wong, linux-xfs, linux-kernel
  Cc: linfeilong, wuguanghao

On 8/22/22 6:46 AM, Zhiqiang Liu wrote:
> 
> In xfs_attri_log_nameval_alloc(), xlog_kvmalloc() is called
> to alloc memory, which will always return
> successfully, so we donot need to check return value.
> 
> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>

I think this is fine. xlog_kvmalloc loops until success, and its other
caller does not check the return value.

This isn't really strictly a fix (it's harmless) but it "fixes"

Fixes: commit 4183e4f27f402 ("xfs: share xattr name and value buffers when logging xattr updates")

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

That said, I think that xfs_attri_log_nameval_alloc() also cannot fail, so
perhaps its callers don't need checks either?

> ---
>  fs/xfs/xfs_attr_item.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c
> index 5077a7ad5646..667e151a2bca 100644
> --- a/fs/xfs/xfs_attr_item.c
> +++ b/fs/xfs/xfs_attr_item.c
> @@ -86,8 +86,6 @@ xfs_attri_log_nameval_alloc(
>  	 */
>  	nv = xlog_kvmalloc(sizeof(struct xfs_attri_log_nameval) +
>  					name_len + value_len);
> -	if (!nv)
> -		return nv;
> 
>  	nv->name.i_addr = nv + 1;
>  	nv->name.i_len = name_len;

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

* Re: [PATCH] xfs: donot need to check return value of xlog_kvmalloc()
  2022-08-29 16:06 ` Eric Sandeen
@ 2022-08-31  9:48   ` Zhiqiang Liu
  0 siblings, 0 replies; 4+ messages in thread
From: Zhiqiang Liu @ 2022-08-31  9:48 UTC (permalink / raw)
  To: Eric Sandeen, Darrick J. Wong, linux-xfs, linux-kernel
  Cc: linfeilong, wuguanghao


On 2022/8/30 0:06, Eric Sandeen wrote:
> On 8/22/22 6:46 AM, Zhiqiang Liu wrote:
>> In xfs_attri_log_nameval_alloc(), xlog_kvmalloc() is called
>> to alloc memory, which will always return
>> successfully, so we donot need to check return value.
>>
>> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
> I think this is fine. xlog_kvmalloc loops until success, and its other
> caller does not check the return value.
>
> This isn't really strictly a fix (it's harmless) but it "fixes"
>
> Fixes: commit 4183e4f27f402 ("xfs: share xattr name and value buffers when logging xattr updates")
>
> Reviewed-by: Eric Sandeen <sandeen@redhat.com>

Thanks for your reply.

Before xlog_kvmalloc was changed to "loops until success", the sanity check was necessary.

As you said, this isn't really strictly a fix, so I think we should not add the Fix tag.

> That said, I think that xfs_attri_log_nameval_alloc() also cannot fail, so
> perhaps its callers don't need checks either?
Yes, you are right. I will clean it up in the V2 patch.

>> ---
>>  fs/xfs/xfs_attr_item.c | 2 --
>>  1 file changed, 2 deletions(-)
>>
>> diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c
>> index 5077a7ad5646..667e151a2bca 100644
>> --- a/fs/xfs/xfs_attr_item.c
>> +++ b/fs/xfs/xfs_attr_item.c
>> @@ -86,8 +86,6 @@ xfs_attri_log_nameval_alloc(
>>  	 */
>>  	nv = xlog_kvmalloc(sizeof(struct xfs_attri_log_nameval) +
>>  					name_len + value_len);
>> -	if (!nv)
>> -		return nv;
>>
>>  	nv->name.i_addr = nv + 1;
>>  	nv->name.i_len = name_len;
> .


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

end of thread, other threads:[~2022-08-31  9:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-22 11:46 [PATCH] xfs: donot need to check return value of xlog_kvmalloc() Zhiqiang Liu
2022-08-27  3:11 ` Zhiqiang Liu
2022-08-29 16:06 ` Eric Sandeen
2022-08-31  9:48   ` Zhiqiang Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.