]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
nfsd: Change the type of ek_fsidtype from int to u8 and use kstrtou8
authorSu Hui <suhui@nfschina.com>
Wed, 4 Jun 2025 03:47:26 +0000 (11:47 +0800)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 14 Jul 2025 16:46:39 +0000 (12:46 -0400)
The valid values for ek_fsidtype are actually 0-7 so it's better to
change the type to u8. Also using kstrtou8() to relpace simple_strtoul(),
kstrtou8() is safer and more suitable for u8.

Suggested-by: NeilBrown <neil@brown.name>
Signed-off-by: Su Hui <suhui@nfschina.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/export.c
fs/nfsd/export.h
fs/nfsd/trace.h

index 88ae410b411333531328c8f6dbce4a94f9998506..cadfc2bae60ea14a90a85c29026a0b7603080531 100644 (file)
@@ -82,8 +82,7 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
        int len;
        struct auth_domain *dom = NULL;
        int err;
-       int fsidtype;
-       char *ep;
+       u8 fsidtype;
        struct svc_expkey key;
        struct svc_expkey *ek = NULL;
 
@@ -109,10 +108,9 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
        err = -EINVAL;
        if (qword_get(&mesg, buf, PAGE_SIZE) <= 0)
                goto out;
-       fsidtype = simple_strtoul(buf, &ep, 10);
-       if (*ep)
+       if (kstrtou8(buf, 10, &fsidtype))
                goto out;
-       dprintk("found fsidtype %d\n", fsidtype);
+       dprintk("found fsidtype %u\n", fsidtype);
        if (key_len(fsidtype)==0) /* invalid type */
                goto out;
        if ((len=qword_get(&mesg, buf, PAGE_SIZE)) <= 0)
index 4d92b99c1ffdd9d4656c2548fc672b7f58a0ec23..b9c0adb3ce09186695f6ec4164ccbf550309a4c4 100644 (file)
@@ -88,7 +88,7 @@ struct svc_expkey {
        struct cache_head       h;
 
        struct auth_domain *    ek_client;
-       int                     ek_fsidtype;
+       u8                      ek_fsidtype;
        u32                     ek_fsid[6];
 
        struct path             ek_path;
index 3c5505ef5e3a38d805a48ea4e190063b5341684d..b244c6b3e9050531f581eb597ff9506f97284e24 100644 (file)
@@ -344,7 +344,7 @@ TRACE_EVENT(nfsd_exp_find_key,
                 int status),
        TP_ARGS(key, status),
        TP_STRUCT__entry(
-               __field(int, fsidtype)
+               __field(u8, fsidtype)
                __array(u32, fsid, 6)
                __string(auth_domain, key->ek_client->name)
                __field(int, status)
@@ -367,7 +367,7 @@ TRACE_EVENT(nfsd_expkey_update,
        TP_PROTO(const struct svc_expkey *key, const char *exp_path),
        TP_ARGS(key, exp_path),
        TP_STRUCT__entry(
-               __field(int, fsidtype)
+               __field(u8, fsidtype)
                __array(u32, fsid, 6)
                __string(auth_domain, key->ek_client->name)
                __string(path, exp_path)