diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2007-10-26 13:32:40 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2008-01-30 02:05:46 -0500 |
commit | 6a0ed1de8ecee0cde21ea667891a03f6c84ecd66 (patch) | |
tree | 898a769a98459e55d1ccd957c09d8cc3f0311833 /fs/nfs/super.c | |
parent | e887cbcf911b2d16742832b38411559273ce5d77 (diff) |
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: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/super.c')
-rw-r--r-- | fs/nfs/super.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 330c3922739f..a3492d6f8f9b 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c | |||
@@ -1648,21 +1648,16 @@ static int nfs4_validate_mount_data(void *options, | |||
1648 | len = c - dev_name; | 1648 | len = c - dev_name; |
1649 | if (len > NFS4_MAXNAMLEN) | 1649 | if (len > NFS4_MAXNAMLEN) |
1650 | return -ENAMETOOLONG; | 1650 | return -ENAMETOOLONG; |
1651 | args->nfs_server.hostname = kzalloc(len, GFP_KERNEL); | 1651 | /* N.B. caller will free nfs_server.hostname in all cases */ |
1652 | if (args->nfs_server.hostname == NULL) | 1652 | args->nfs_server.hostname = kstrndup(dev_name, len, GFP_KERNEL); |
1653 | return -ENOMEM; | ||
1654 | strncpy(args->nfs_server.hostname, dev_name, len - 1); | ||
1655 | 1653 | ||
1656 | c++; /* step over the ':' */ | 1654 | c++; /* step over the ':' */ |
1657 | len = strlen(c); | 1655 | len = strlen(c); |
1658 | if (len > NFS4_MAXPATHLEN) | 1656 | if (len > NFS4_MAXPATHLEN) |
1659 | return -ENAMETOOLONG; | 1657 | return -ENAMETOOLONG; |
1660 | args->nfs_server.export_path = kzalloc(len + 1, GFP_KERNEL); | 1658 | args->nfs_server.export_path = kstrndup(c, len, GFP_KERNEL); |
1661 | if (args->nfs_server.export_path == NULL) | ||
1662 | return -ENOMEM; | ||
1663 | strncpy(args->nfs_server.export_path, c, len); | ||
1664 | 1659 | ||
1665 | dprintk("MNTPATH: %s\n", args->nfs_server.export_path); | 1660 | dprintk("NFS: MNTPATH: '%s'\n", args->nfs_server.export_path); |
1666 | 1661 | ||
1667 | if (args->client_address == NULL) | 1662 | if (args->client_address == NULL) |
1668 | goto out_no_client_address; | 1663 | goto out_no_client_address; |