]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
do_nfs4_mount(): switch to vfs_parse_fs_string()
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 20 Jul 2025 19:48:00 +0000 (15:48 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 4 Sep 2025 19:20:58 +0000 (15:20 -0400)
Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/nfs/nfs4super.c

index b29a26923ce092e853ea90c8c00d05045a689ed8..5ec9c83f1ef088d2388ddc9e24a98a76167ed63d 100644 (file)
@@ -149,21 +149,9 @@ static int do_nfs4_mount(struct nfs_server *server,
        struct fs_context *root_fc;
        struct vfsmount *root_mnt;
        struct dentry *dentry;
-       size_t len;
+       char *source;
        int ret;
 
-       struct fs_parameter param = {
-               .key    = "source",
-               .type   = fs_value_is_string,
-               .dirfd  = -1,
-       };
-
-       struct fs_parameter param_fsc = {
-               .key    = "fsc",
-               .type   = fs_value_is_string,
-               .dirfd  = -1,
-       };
-
        if (IS_ERR(server))
                return PTR_ERR(server);
 
@@ -181,15 +169,7 @@ static int do_nfs4_mount(struct nfs_server *server,
        root_ctx->server = server;
 
        if (ctx->fscache_uniq) {
-               len = strlen(ctx->fscache_uniq);
-               param_fsc.size = len;
-               param_fsc.string = kmemdup_nul(ctx->fscache_uniq, len, GFP_KERNEL);
-               if (param_fsc.string == NULL) {
-                       put_fs_context(root_fc);
-                       return -ENOMEM;
-               }
-               ret = vfs_parse_fs_param(root_fc, &param_fsc);
-               kfree(param_fsc.string);
+               ret = vfs_parse_fs_string(root_fc, "fsc", ctx->fscache_uniq);
                if (ret < 0) {
                        put_fs_context(root_fc);
                        return ret;
@@ -197,20 +177,18 @@ static int do_nfs4_mount(struct nfs_server *server,
        }
        /* We leave export_path unset as it's not used to find the root. */
 
-       len = strlen(hostname) + 5;
-       param.string = kmalloc(len, GFP_KERNEL);
-       if (param.string == NULL) {
-               put_fs_context(root_fc);
-               return -ENOMEM;
-       }
-
        /* Does hostname needs to be enclosed in brackets? */
        if (strchr(hostname, ':'))
-               param.size = snprintf(param.string, len, "[%s]:/", hostname);
+               source = kasprintf(GFP_KERNEL, "[%s]:/", hostname);
        else
-               param.size = snprintf(param.string, len, "%s:/", hostname);
-       ret = vfs_parse_fs_param(root_fc, &param);
-       kfree(param.string);
+               source = kasprintf(GFP_KERNEL, "%s:/", hostname);
+
+       if (!source) {
+               put_fs_context(root_fc);
+               return -ENOMEM;
+       }
+       ret = vfs_parse_fs_string(root_fc, "source", source);
+       kfree(source);
        if (ret < 0) {
                put_fs_context(root_fc);
                return ret;