[PATCH 2/2] xfs: remove the extra processing of zero size in xfs_idata_realloc()

From: Zhen Lei
Date: Tue Nov 24 2020 - 05:46:27 EST


krealloc() does the free operation when the parameter new_size is 0, with
ZERO_SIZE_PTR returned. Because all other places use NULL to check whether
if_data is available or not, so covert it from ZERO_SIZE_PTR to NULL.

Signed-off-by: Zhen Lei <thunder.leizhen@xxxxxxxxxx>
---
fs/xfs/libxfs/xfs_inode_fork.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
index 4e457aea8493..518af4088e79 100644
--- a/fs/xfs/libxfs/xfs_inode_fork.c
+++ b/fs/xfs/libxfs/xfs_inode_fork.c
@@ -492,13 +492,6 @@ xfs_idata_realloc(
if (byte_diff == 0)
return;

- if (new_size == 0) {
- kmem_free(ifp->if_u1.if_data);
- ifp->if_u1.if_data = NULL;
- ifp->if_bytes = 0;
- return;
- }
-
/*
* For inline data, the underlying buffer must be a multiple of 4 bytes
* in size so that it can be logged and stay on word boundaries.
@@ -510,7 +503,7 @@ xfs_idata_realloc(
WARN(1, "if_data realloc failed\n");
return;
}
- ifp->if_u1.if_data = if_data;
+ ifp->if_u1.if_data = ZERO_OR_NULL_PTR(if_data) ? NULL : if_data;
ifp->if_bytes = new_size;
}

--
2.26.0.106.g9fadedd