mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: Chuck Lever <chuck.lever@oracle.com>, Neil Brown <neilb@suse.de>,
	 Olga Kornievskaia <kolga@netapp.com>,
	Dai Ngo <Dai.Ngo@oracle.com>,  Tom Talpey <tom@talpey.com>
Cc: Jakub Kicinski <kuba@kernel.org>,
	linux-nfs@vger.kernel.org,  linux-kernel@vger.kernel.org,
	Jeff Layton <jlayton@kernel.org>
Subject: [PATCH] nfsd: fix error handling bug in nfsd_nl_pool_mode_get_doit
Date: Fri, 14 Jun 2024 08:59:10 -0400	[thread overview]
Message-ID: <20240614-nfsd-next-v1-1-d360eea79d0b@kernel.org> (raw)

As Jakub pointed out, I meant to use a bitwise or after the call to
nla_put_string. Also move the sunrpc_get_pool_mode call up in the
function, which simplifies the error handling a bit.

Cc: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
Technically, I think the logical or works just as well as a bitwise or
here, but this is cleaner and maybe slightly more efficient. Chuck,
it's probably best to squash this into 84a570328ee.
---
 fs/nfsd/nfsctl.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index 187e9be77b78..e5d2cc74ef77 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -2214,6 +2214,9 @@ int nfsd_nl_pool_mode_get_doit(struct sk_buff *skb, struct genl_info *info)
 	void *hdr;
 	int err;
 
+	if (sunrpc_get_pool_mode(buf, ARRAY_SIZE(buf)) >= ARRAY_SIZE(buf))
+		return -ERANGE;
+
 	skb = genlmsg_new(GENLMSG_DEFAULT_SIZE, GFP_KERNEL);
 	if (!skb)
 		return -ENOMEM;
@@ -2223,11 +2226,7 @@ int nfsd_nl_pool_mode_get_doit(struct sk_buff *skb, struct genl_info *info)
 	if (!hdr)
 		goto err_free_msg;
 
-	err = -ERANGE;
-	if (sunrpc_get_pool_mode(buf, ARRAY_SIZE(buf)) >= ARRAY_SIZE(buf))
-		goto err_free_msg;
-
-	err = nla_put_string(skb, NFSD_A_POOL_MODE_MODE, buf) ||
+	err = nla_put_string(skb, NFSD_A_POOL_MODE_MODE, buf) |
 	      nla_put_u32(skb, NFSD_A_POOL_MODE_NPOOLS, nfsd_nrpools(net));
 	if (err)
 		goto err_free_msg;

---
base-commit: 84a570328eefd4df2e201deb5d43d152e0aca55a
change-id: 20240614-nfsd-next-d5f6bbdf027d

Best regards,
-- 
Jeff Layton <jlayton@kernel.org>


             reply	other threads:[~2024-06-14 12:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-14 12:59 Jeff Layton [this message]
2024-06-14 13:24 ` Chuck Lever

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=20240614-nfsd-next-v1-1-d360eea79d0b@kernel.org \
    --to=jlayton@kernel.org \
    --cc=Dai.Ngo@oracle.com \
    --cc=chuck.lever@oracle.com \
    --cc=kolga@netapp.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=tom@talpey.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®