[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3bd1932129f4221a7affc5a6bf1ea5367dcb6a7c.camel@kernel.org>
Date: Wed, 28 May 2025 07:11:19 -0400
From: Jeff Layton <jlayton@...nel.org>
To: Su Hui <suhui@...china.com>, chuck.lever@...cle.com, neilb@...e.de,
okorniev@...hat.com, Dai.Ngo@...cle.com, tom@...pey.com
Cc: linux-nfs@...r.kernel.org, linux-kernel@...r.kernel.org,
kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] nfsd: Replace simple_strtoul with kstrtoint in
expkey_parse
On Tue, 2025-05-27 at 17:25 +0800, Su Hui wrote:
> kstrtoint() is better because simple_strtoul() ignores overflow and the
> type of 'fsidtype' is 'int' rather than 'unsigned long'.
>
> Signed-off-by: Su Hui <suhui@...china.com>
> ---
> fs/nfsd/export.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
> index 0363720280d4..1bc9bc20cac3 100644
> --- a/fs/nfsd/export.c
> +++ b/fs/nfsd/export.c
> @@ -83,7 +83,6 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
> struct auth_domain *dom = NULL;
> int err;
> int fsidtype;
> - char *ep;
> struct svc_expkey key;
> struct svc_expkey *ek = NULL;
>
> @@ -109,8 +108,7 @@ 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 (kstrtoint(buf, 10, &fsidtype))
> goto out;
> dprintk("found fsidtype %d\n", fsidtype);
> if (key_len(fsidtype)==0) /* invalid type */
Reviewed-by: Jeff Layton <jlayton@...nel.org>
Powered by blists - more mailing lists