linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: smayhew@redhat.com
Cc: linux-fsdevel@vger.kernel.org
Subject: [bug report] NFS: Convert mount option parsing to use functionality from fs_parser.h
Date: Fri, 15 May 2020 14:44:26 +0300	[thread overview]
Message-ID: <20200515114426.GA574054@mwanda> (raw)

Hello Scott Mayhew,

The patch e38bb238ed8c: "NFS: Convert mount option parsing to use
functionality from fs_parser.h" from Dec 10, 2019, leads to the
following static checker warning:

	fs/namespace.c:1011 vfs_kern_mount()
	error: passing non negative 1 to ERR_PTR

fs/namespace.c
   988  struct vfsmount *vfs_kern_mount(struct file_system_type *type,
   989                                  int flags, const char *name,
   990                                  void *data)
   991  {
   992          struct fs_context *fc;
   993          struct vfsmount *mnt;
   994          int ret = 0;
   995  
   996          if (!type)
   997                  return ERR_PTR(-EINVAL);
   998  
   999          fc = fs_context_for_mount(type, flags);
  1000          if (IS_ERR(fc))
  1001                  return ERR_CAST(fc);
  1002  
  1003          if (name)
  1004                  ret = vfs_parse_fs_string(fc, "source",
  1005                                            name, strlen(name));

The nfs_fs_context_parse_param() function returns 1 if ->sloppy is true.
There are no comments explaining what the 1 means, but the comments for
vfs_parse_fs_param() say it should only return zero or negative error
codes.

        opt = fs_parse(fc, nfs_fs_parameters, param, &result);
        if (opt < 0)
                return ctx->sloppy ? 1 : opt;

I feel like this code is buggy, but if it's not then it really needs
some documentation.

  1006          if (!ret)
  1007                  ret = parse_monolithic_mount_data(fc, data);
  1008          if (!ret)
  1009                  mnt = fc_mount(fc);
  1010          else
  1011                  mnt = ERR_PTR(ret);
  1012  
  1013          put_fs_context(fc);
  1014          return mnt;
  1015  }
  1016  EXPORT_SYMBOL_GPL(vfs_kern_mount);

regards,
dan carpenter

                 reply	other threads:[~2020-05-15 11:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20200515114426.GA574054@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=smayhew@redhat.com \
    /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;
as well as URLs for NNTP newsgroup(s).