Skip to contentSkip to conversation

btrfs: sysfs: fix return value check in btrfs_force_chunk_alloc_s()

PATCH In review Wei Yongjun 2 participants 2 messages Jun 8, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: sysfs: fix return value check in btrfs_force_chunk_alloc_s()

In case of error, the function btrfs_start_transaction() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR().

Fixes 46e1bce0ac34 ("btrfs: sysfs: add force_chunk_alloc trigger to force allocation")
---
 fs/btrfs/sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/sysfs.c +1 -1
index ebe76d7a4a64..4186fdcbcdee 100644
@@ -807,7 +807,7 @@ static ssize_t btrfs_force_chunk_alloc_store(struct kobject *kobj,
 	 * unexpected problems.
 	 */
 	trans = btrfs_start_transaction(fs_info->tree_root, 0);
-	if (!trans)
+	if (IS_ERR(trans))
 		return PTR_ERR(trans);
 	ret = btrfs_force_chunk_alloc(trans, space_info->flags);
 	btrfs_end_transaction(trans);
#1 lore raw
Quoted 7 lines · Wei Yongjun

In case of error, the function btrfs_start_transaction() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR().

Fixes 46e1bce0ac34 ("btrfs: sysfs: add force_chunk_alloc trigger to force allocation")

Thanks, fix folded to the patch as it's still in the development branch.