Skip to content

Commit fdc368e

Browse files
Su Huichucklever
authored andcommitted
nfsd: Change the type of ek_fsidtype from int to u8 and use kstrtou8
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>
1 parent f26c930 commit fdc368e

3 files changed

Lines changed: 6 additions & 8 deletions

File tree

fs/nfsd/export.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
8282
int len;
8383
struct auth_domain *dom = NULL;
8484
int err;
85-
int fsidtype;
86-
char *ep;
85+
u8 fsidtype;
8786
struct svc_expkey key;
8887
struct svc_expkey *ek = NULL;
8988

@@ -109,10 +108,9 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
109108
err = -EINVAL;
110109
if (qword_get(&mesg, buf, PAGE_SIZE) <= 0)
111110
goto out;
112-
fsidtype = simple_strtoul(buf, &ep, 10);
113-
if (*ep)
111+
if (kstrtou8(buf, 10, &fsidtype))
114112
goto out;
115-
dprintk("found fsidtype %d\n", fsidtype);
113+
dprintk("found fsidtype %u\n", fsidtype);
116114
if (key_len(fsidtype)==0) /* invalid type */
117115
goto out;
118116
if ((len=qword_get(&mesg, buf, PAGE_SIZE)) <= 0)

fs/nfsd/export.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ struct svc_expkey {
8888
struct cache_head h;
8989

9090
struct auth_domain * ek_client;
91-
int ek_fsidtype;
91+
u8 ek_fsidtype;
9292
u32 ek_fsid[6];
9393

9494
struct path ek_path;

fs/nfsd/trace.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ TRACE_EVENT(nfsd_exp_find_key,
344344
int status),
345345
TP_ARGS(key, status),
346346
TP_STRUCT__entry(
347-
__field(int, fsidtype)
347+
__field(u8, fsidtype)
348348
__array(u32, fsid, 6)
349349
__string(auth_domain, key->ek_client->name)
350350
__field(int, status)
@@ -367,7 +367,7 @@ TRACE_EVENT(nfsd_expkey_update,
367367
TP_PROTO(const struct svc_expkey *key, const char *exp_path),
368368
TP_ARGS(key, exp_path),
369369
TP_STRUCT__entry(
370-
__field(int, fsidtype)
370+
__field(u8, fsidtype)
371371
__array(u32, fsid, 6)
372372
__string(auth_domain, key->ek_client->name)
373373
__string(path, exp_path)

0 commit comments

Comments
 (0)