summaryrefslogtreecommitdiffstats
path: root/fs/cifs
diff options
context:
space:
mode:
authorSean Finney <seanius@seanius.net>2011-04-11 13:19:34 +0000
committerSteve French <sfrench@us.ibm.com>2011-05-19 14:10:55 +0000
commit5167f11ec962690ecf926fab00f1d0524cd78664 (patch)
tree06797f7f000ad72df4127fa78c673772d93ddede /fs/cifs
parent046462abca2576cc1c71f501c148798fac4ea314 (diff)
downloadop-kernel-dev-5167f11ec962690ecf926fab00f1d0524cd78664.zip
op-kernel-dev-5167f11ec962690ecf926fab00f1d0524cd78664.tar.gz
cifs: Use kstrndup for cifs_sb->mountdata
A relatively minor nit, but also clarified the "consensus" from the preceding comments that it is in fact better to try for the kstrdup early and cleanup while cleaning up is still a simple thing to do. Reviewed-By: Steve French <smfrench@gmail.com> Signed-off-by: Sean Finney <seanius@seanius.net> Signed-off-by: Pavel Shilovsky <piastry@etersoft.ru> Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs')
-rw-r--r--fs/cifs/cifsfs.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 0f6a54f..bb39afc 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -129,24 +129,19 @@ cifs_read_super(struct super_block *sb, void *data,
cifs_sb->bdi.ra_pages = default_backing_dev_info.ra_pages;
#ifdef CONFIG_CIFS_DFS_UPCALL
- /* copy mount params to sb for use in submounts */
- /* BB: should we move this after the mount so we
- * do not have to do the copy on failed mounts?
- * BB: May be it is better to do simple copy before
- * complex operation (mount), and in case of fail
- * just exit instead of doing mount and attempting
- * undo it if this copy fails?*/
+ /*
+ * Copy mount params to sb for use in submounts. Better to do
+ * the copy here and deal with the error before cleanup gets
+ * complicated post-mount.
+ */
if (data) {
- int len = strlen(data);
- cifs_sb->mountdata = kzalloc(len + 1, GFP_KERNEL);
+ cifs_sb->mountdata = kstrndup(data, PAGE_SIZE, GFP_KERNEL);
if (cifs_sb->mountdata == NULL) {
bdi_destroy(&cifs_sb->bdi);
kfree(sb->s_fs_info);
sb->s_fs_info = NULL;
return -ENOMEM;
}
- strncpy(cifs_sb->mountdata, data, len + 1);
- cifs_sb->mountdata[len] = '\0';
}
#endif
OpenPOWER on IntegriCloud