From: Wu Bo <wubo40@huawei.com>
To: <josef@toxicpanda.com>, <axboe@kernel.dk>
Cc: <linux-block@vger.kernel.org>, <nbd@other.debian.org>,
<linux-kernel@vger.kernel.org>, <linfeilong@huawei.com>,
<wubo40@huawei.com>
Subject: [PATCH RESEND] nbd: code clean for nbd_genl_status()
Date: Thu, 4 Nov 2021 12:38:23 +0800 [thread overview]
Message-ID: <1636000703-13217-1-git-send-email-wubo40@huawei.com> (raw)
A simple code clean for nbd_genl_status()
Signed-off-by: Wu Bo <wubo40@huawei.com>
---
drivers/block/nbd.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index b47b2a8..175ea97 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -2375,7 +2375,6 @@ static int nbd_genl_status(struct sk_buff *skb, struct genl_info *info)
reply_head = genlmsg_put_reply(reply, info, &nbd_genl_family, 0,
NBD_CMD_STATUS);
if (!reply_head) {
- nlmsg_free(reply);
goto out;
}
@@ -2383,7 +2382,6 @@ static int nbd_genl_status(struct sk_buff *skb, struct genl_info *info)
if (index == -1) {
ret = idr_for_each(&nbd_index_idr, &status_cb, reply);
if (ret) {
- nlmsg_free(reply);
goto out;
}
} else {
@@ -2392,7 +2390,6 @@ static int nbd_genl_status(struct sk_buff *skb, struct genl_info *info)
if (nbd) {
ret = populate_nbd_status(nbd, reply);
if (ret) {
- nlmsg_free(reply);
goto out;
}
}
@@ -2401,6 +2398,8 @@ static int nbd_genl_status(struct sk_buff *skb, struct genl_info *info)
genlmsg_end(reply, reply_head);
ret = genlmsg_reply(reply, info);
out:
+ if (reply)
+ nlmsg_free(reply);
mutex_unlock(&nbd_index_mutex);
return ret;
}
--
1.8.3.1
next reply other threads:[~2021-11-04 4:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-04 4:38 Wu Bo [this message]
2021-11-04 8:48 ` [PATCH RESEND] nbd: code clean for nbd_genl_status() Christoph Hellwig
2021-11-05 1:46 ` Wu Bo
2021-11-05 10:01 ` Josef Bacik
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=1636000703-13217-1-git-send-email-wubo40@huawei.com \
--to=wubo40@huawei.com \
--cc=axboe@kernel.dk \
--cc=josef@toxicpanda.com \
--cc=linfeilong@huawei.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nbd@other.debian.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox