Skip to contentSkip to conversation

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

PATCH In review Zhiqiang Liu 2 participants 2 messages Sep 1, 2022 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH v2 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.

---
Changelog:
V1 -> V2:
1.add Reviewed-by: Eric Sandeen <[email protected]> 2.remove santity check of xfs_attri_log_nameval_alloc()
suggested by Eric Sandeen.

 fs/xfs/xfs_attr_item.c | 6 ------
 1 file changed, 6 deletions(-)
fs/xfs/xfs_attr_item.c +0 -6
index 5077a7ad5646..cf5ce607dc05 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;
@@ -441,8 +439,6 @@ xfs_attr_create_intent(
 		attr->xattri_nameval = xfs_attri_log_nameval_alloc(args->name,
 				args->namelen, args->value, args->valuelen);
 	}
-	if (!attr->xattri_nameval)
-		return ERR_PTR(-ENOMEM);
 
 	attrip = xfs_attri_init(mp, attr->xattri_nameval);
 	xfs_trans_add_item(tp, &attrip->attri_item);
@@ -762,8 +758,6 @@ xlog_recover_attri_commit_pass2(
 	nv = xfs_attri_log_nameval_alloc(attr_name,
 			attri_formatp->alfi_name_len, attr_value,
 			attri_formatp->alfi_value_len);
-	if (!nv)
-		return -ENOMEM;
 
 	attrip = xfs_attri_init(mp, nv);
 	error = xfs_attri_copy_format(&item->ri_buf[0], &attrip->attri_format);
Signature · 1 line
2.33.0
Reviewed-by on v2 1/1
#1 lore raw
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.

Makes sense...

--D

Quoted 44 lines

---
Changelog:
V1 -> V2:
1.add Reviewed-by: Eric Sandeen <[email protected]> 2.remove santity check of xfs_attri_log_nameval_alloc()
suggested by Eric Sandeen.

 fs/xfs/xfs_attr_item.c | 6 ------
 1 file changed, 6 deletions(-)
fs/xfs/xfs_attr_item.c +0 -6
index 5077a7ad5646..cf5ce607dc05 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;
@@ -441,8 +439,6 @@ xfs_attr_create_intent(
 		attr->xattri_nameval = xfs_attri_log_nameval_alloc(args->name,
 				args->namelen, args->value, args->valuelen);
 	}
-	if (!attr->xattri_nameval)
-		return ERR_PTR(-ENOMEM);
 
 	attrip = xfs_attri_init(mp, attr->xattri_nameval);
 	xfs_trans_add_item(tp, &attrip->attri_item);
@@ -762,8 +758,6 @@ xlog_recover_attri_commit_pass2(
 	nv = xfs_attri_log_nameval_alloc(attr_name,
 			attri_formatp->alfi_name_len, attr_value,
 			attri_formatp->alfi_value_len);
-	if (!nv)
-		return -ENOMEM;
 
 	attrip = xfs_attri_init(mp, nv);
 	error = xfs_attri_copy_format(&item->ri_buf[0], &attrip->attri_format);
Signature · 1 line
2.33.0