Thread (6 messages) 6 messages, 3 authors, 2022-02-22
STALE1612d LANDED

[PATCH 2/2] null_blk: null_alloc_page() cleanup

From: Chaitanya Kulkarni <kch@nvidia.com>
Date: 2022-02-22 15:29:28
Subsystem: block layer, the rest · Maintainers: Jens Axboe, Linus Torvalds

Remove goto labels and use direct returns as error unwinding code only
needs to free t_page variable if we alloc_pages() call fails as having
two labels for one kfree() can be avoided easily.

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 drivers/block/null_blk/main.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index 80f9a6ba376d..05b1120e6623 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -783,18 +783,16 @@ static struct nullb_page *null_alloc_page(void)
 
 	t_page = kmalloc(sizeof(struct nullb_page), GFP_NOIO);
 	if (!t_page)
-		goto out;
+		return NULL;
 
 	t_page->page = alloc_pages(GFP_NOIO, 0);
-	if (!t_page->page)
-		goto out_freepage;
+	if (!t_page->page) {
+		kfree(t_page);
+		return NULL;
+	}
 
 	memset(t_page->bitmap, 0, sizeof(t_page->bitmap));
 	return t_page;
-out_freepage:
-	kfree(t_page);
-out:
-	return NULL;
 }
 
 static void null_free_page(struct nullb_page *t_page)
-- 
2.29.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help