Commit 6a0ed1de authored by Chuck Lever's avatar Chuck Lever Committed by Trond Myklebust

NFS: Clean up: copy hostname with kstrndup during mount processing

Clean up: mount option parsing uses kstrndup in several places, rather than
using kzalloc.  Replace the few remaining uses of kzalloc with kstrndup,
for consistency.
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent e887cbcf
...@@ -1648,21 +1648,16 @@ static int nfs4_validate_mount_data(void *options, ...@@ -1648,21 +1648,16 @@ static int nfs4_validate_mount_data(void *options,
len = c - dev_name; len = c - dev_name;
if (len > NFS4_MAXNAMLEN) if (len > NFS4_MAXNAMLEN)
return -ENAMETOOLONG; return -ENAMETOOLONG;
args->nfs_server.hostname = kzalloc(len, GFP_KERNEL); /* N.B. caller will free nfs_server.hostname in all cases */
if (args->nfs_server.hostname == NULL) args->nfs_server.hostname = kstrndup(dev_name, len, GFP_KERNEL);
return -ENOMEM;
strncpy(args->nfs_server.hostname, dev_name, len - 1);
c++; /* step over the ':' */ c++; /* step over the ':' */
len = strlen(c); len = strlen(c);
if (len > NFS4_MAXPATHLEN) if (len > NFS4_MAXPATHLEN)
return -ENAMETOOLONG; return -ENAMETOOLONG;
args->nfs_server.export_path = kzalloc(len + 1, GFP_KERNEL); args->nfs_server.export_path = kstrndup(c, len, GFP_KERNEL);
if (args->nfs_server.export_path == NULL)
return -ENOMEM;
strncpy(args->nfs_server.export_path, c, len);
dprintk("MNTPATH: %s\n", args->nfs_server.export_path); dprintk("NFS: MNTPATH: '%s'\n", args->nfs_server.export_path);
if (args->client_address == NULL) if (args->client_address == NULL)
goto out_no_client_address; goto out_no_client_address;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment