nfsd: fix error handling bug in nfsd_nl_pool_mode_get_doit
Subsystems (2)
Jeff Layton
maintainerPATCH 1/1 nfsd: fix error handling bug in nfsd_nl_pool_mode_get_doit
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.
---
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(-)
fs/nfsd/nfsctl.c +4 -5
@@ -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,
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 10 lines · Jeff Layton
As Jakub pointed out, I meant to use a bitwise or after the call to
nla_put_string. Also move thesunrpc_get_pool_modecall up in the function, which simplifies the error handling a bit.Cc Jakub Kicinski <[email protected]>Signed-off-by Jeff Layton <[email protected]>---
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 into84a570328ee.
Done, and pushed to nfsd-next.
Quoted 40 lines
--- fs/nfsd/nfsctl.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)fs/nfsd/nfsctl.c +4
-6@@ -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-d5f6bbdf027dBest regards,
Signature · 1 line
Jeff Layton <[email protected]>
Signature · 1 line
Chuck Lever