All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chaitanya Kulkarni <kch@nvidia.com>
To: <linux-block@vger.kernel.org>
Cc: <axboe@kernel.dk>, <ming.lei@redhat.com>, <damien.lemoal@wdc.com>,
	<shinichiro.kawasaki@wdc.com>,
	Chaitanya Kulkarni <kch@nvidia.com>
Subject: [PATCH 2/2] null_blk: null_alloc_page() cleanup
Date: Tue, 22 Feb 2022 07:28:52 -0800	[thread overview]
Message-ID: <20220222152852.26043-3-kch@nvidia.com> (raw)
In-Reply-To: <20220222152852.26043-1-kch@nvidia.com>

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


  parent reply	other threads:[~2022-02-22 15:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-22 15:28 [PATCH 0/2] null_blk: null_alloc_page() cleanup Chaitanya Kulkarni
2022-02-22 15:28 ` [PATCH 1/2] null_blk: remove hardcoded null_alloc_page() param Chaitanya Kulkarni
2022-02-22 16:06   ` Christoph Hellwig
2022-02-22 15:28 ` Chaitanya Kulkarni [this message]
2022-02-22 16:06   ` [PATCH 2/2] null_blk: null_alloc_page() cleanup Christoph Hellwig
2022-02-22 20:00 ` [PATCH 0/2] " Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220222152852.26043-3-kch@nvidia.com \
    --to=kch@nvidia.com \
    --cc=axboe@kernel.dk \
    --cc=damien.lemoal@wdc.com \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=shinichiro.kawasaki@wdc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.