public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: make error handling more appropriate in btrfs_delayed_ref_init()
@ 2025-04-10 11:38 Yangtao Li
  2025-04-14  9:37 ` David Sterba
  0 siblings, 1 reply; 2+ messages in thread
From: Yangtao Li @ 2025-04-10 11:38 UTC (permalink / raw)
  To: clm, josef, dsterba; +Cc: linux-btrfs, linux-kernel, Yangtao Li

1. Remove unnecessary goto
2. Make the execution logic of the function jumped by goto more appropriate

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 fs/btrfs/delayed-ref.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
index 98c5b61dabe8..e984f1761afa 100644
--- a/fs/btrfs/delayed-ref.c
+++ b/fs/btrfs/delayed-ref.c
@@ -1339,11 +1339,11 @@ int __init btrfs_delayed_ref_init(void)
 {
 	btrfs_delayed_ref_head_cachep = KMEM_CACHE(btrfs_delayed_ref_head, 0);
 	if (!btrfs_delayed_ref_head_cachep)
-		goto fail;
+		return -ENOMEM;
 
 	btrfs_delayed_ref_node_cachep = KMEM_CACHE(btrfs_delayed_ref_node, 0);
 	if (!btrfs_delayed_ref_node_cachep)
-		goto fail;
+		goto out;
 
 	btrfs_delayed_extent_op_cachep = KMEM_CACHE(btrfs_delayed_extent_op, 0);
 	if (!btrfs_delayed_extent_op_cachep)
@@ -1351,6 +1351,8 @@ int __init btrfs_delayed_ref_init(void)
 
 	return 0;
 fail:
-	btrfs_delayed_ref_exit();
+	kmem_cache_destroy(btrfs_delayed_ref_node_cachep);
+out:
+	kmem_cache_destroy(btrfs_delayed_ref_head_cachep);
 	return -ENOMEM;
 }
-- 
2.39.0


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

end of thread, other threads:[~2025-04-14  9:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-10 11:38 [PATCH] btrfs: make error handling more appropriate in btrfs_delayed_ref_init() Yangtao Li
2025-04-14  9:37 ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox