mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Trond Myklebust <trondmy@hammerspace.com>
To: "cymi20@fudan.edu.cn" <cymi20@fudan.edu.cn>
Cc: "anna@kernel.org" <anna@kernel.org>,
	"linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] nfsroot: Fix missing check for return value of strsep()
Date: Wed, 14 Jun 2023 15:19:59 +0000	[thread overview]
Message-ID: <83fd43a8acec2d07ee7bd49afc830988354784ed.camel@hammerspace.com> (raw)
In-Reply-To: <20230614143058.112300-1-cymi20@fudan.edu.cn>

On Wed, 2023-06-14 at 07:30 -0700, Chenyuan Mi wrote:
> [You don't often get email from cymi20@fudan.edu.cn. Learn why this
> is important at https://aka.ms/LearnAboutSenderIdentification ]
> 
> The strsep() function in root_nfs_parse_options() may return NULL
> if argument 'incoming' is NULL. Since 'incoming' has Null check in
> this function, it is also need to add Null check for return value
>  of strsep().
> 
> Found by our static analysis tool.
> 
> Signed-off-by: Chenyuan Mi <cymi20@fudan.edu.cn>
> ---
>  fs/nfs/nfsroot.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/nfs/nfsroot.c b/fs/nfs/nfsroot.c
> index 620329b7e6ae..55c594dede9f 100644
> --- a/fs/nfs/nfsroot.c
> +++ b/fs/nfs/nfsroot.c
> @@ -198,7 +198,7 @@ static int __init root_nfs_parse_options(char
> *incoming, char *exppath,
>          * Set the NFS remote path
>          */
>         p = strsep(&incoming, ",");
> -       if (*p != '\0' && strcmp(p, "default") != 0)
> +       if (p != NULL && *p != '\0' && strcmp(p, "default") != 0)
>                 if (root_nfs_copy(exppath, p, exppathlen))
>                         return -1;
> 

Huh? root_nfs_parse_options() is called from exactly two callsites, and
in both cases 'incoming' is guaranteed to be non-NULL.

NACKed
-- 
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trond.myklebust@hammerspace.com



  reply	other threads:[~2023-06-14 15:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-14 14:30 Chenyuan Mi
2023-06-14 15:19 ` Trond Myklebust [this message]
2023-06-14 15:23 ` Benjamin Coddington

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=83fd43a8acec2d07ee7bd49afc830988354784ed.camel@hammerspace.com \
    --to=trondmy@hammerspace.com \
    --cc=anna@kernel.org \
    --cc=cymi20@fudan.edu.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    /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®