linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] NFS: Convert mount option parsing to use functionality from fs_parser.h
@ 2020-05-15 11:44 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2020-05-15 11:44 UTC (permalink / raw)
  To: smayhew; +Cc: linux-fsdevel

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-05-15 11:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-15 11:44 [bug report] NFS: Convert mount option parsing to use functionality from fs_parser.h Dan Carpenter

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).