Skip to contentSkip to conversation

xfs: donot need to check return value of xlog_kvmalloc()

PATCH Superseded Zhiqiang Liu 2 participants 4 messages Aug 22, 2022 – Aug 31, 2022 XFS filesystem

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: donot need to check return value of xlog_kvmalloc()

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.

---
 fs/xfs/xfs_attr_item.c | 2 --
 1 file changed, 2 deletions(-)
fs/xfs/xfs_attr_item.c +0 -2
index 5077a7ad5646..667e151a2bca 100644
@@ -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;
Signature · 1 line
2.33.0
#1 lore raw

friendly ping..

Quoted 22 lines · Zhiqiang Liu

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.

---
 fs/xfs/xfs_attr_item.c | 2 --
 1 file changed, 2 deletions(-)
fs/xfs/xfs_attr_item.c +0 -2
index 5077a7ad5646..667e151a2bca 100644
@@ -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;
Reviewed-by on v1 1/1
#2 lore raw
In reply to Zhiqiang Liu
Quoted 6 lines · Zhiqiang Liu

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.

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

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

Quoted 17 lines
---
 fs/xfs/xfs_attr_item.c | 2 --
 1 file changed, 2 deletions(-)
fs/xfs/xfs_attr_item.c +0 -2
index 5077a7ad5646..667e151a2bca 100644
@@ -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;
#3 lore raw
Quoted 6 lines · Eric Sandeen
Quoted 5 lines · Zhiqiang Liu

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.

Quoted 8 lines

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

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.

Quoted 2 lines

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.

Quoted 18 lines
Quoted 9 lines
---
 fs/xfs/xfs_attr_item.c | 2 --
 1 file changed, 2 deletions(-)
fs/xfs/xfs_attr_item.c +0 -0
index 5077a7ad5646..667e151a2bca 100644

fs/xfs/xfs_attr_item.c xfs_attri_log_nameval_alloc( · line 91

Quoted 8 lines
fs/xfs/xfs_attr_item.c +0 -2
@@ -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;

.