aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorPavel Shilovsky <piastry@etersoft.ru>2011-05-25 16:02:16 -0400
committerSteve French <sfrench@us.ibm.com>2011-05-26 23:45:37 -0400
commit641a58d66d086327042e9d73c6606fd02c8f067c (patch)
treed34ce82a1971daef0735c398924e3161c22b8391 /fs
parent6848b7334b24b47aa3d0e70342ff839ffa95d5fa (diff)
CIFS: Fix memory leak in cifs_do_mount
and simplify error handling code. Signed-off-by: Pavel Shilovsky <piastry@etersoft.ru> Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/cifs/cifsfs.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index d1ed7f9946d..1d2a93c60e7 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -556,9 +556,8 @@ cifs_do_mount(struct file_system_type *fs_type,
556 556
557 sb = sget(fs_type, NULL, set_anon_super, NULL); 557 sb = sget(fs_type, NULL, set_anon_super, NULL);
558 if (IS_ERR(sb)) { 558 if (IS_ERR(sb)) {
559 kfree(cifs_sb);
560 root = ERR_CAST(sb); 559 root = ERR_CAST(sb);
561 goto out; 560 goto out_cifs_sb;
562 } 561 }
563 562
564 /* 563 /*
@@ -569,7 +568,7 @@ cifs_do_mount(struct file_system_type *fs_type,
569 cifs_sb->mountdata = kstrndup(data, PAGE_SIZE, GFP_KERNEL); 568 cifs_sb->mountdata = kstrndup(data, PAGE_SIZE, GFP_KERNEL);
570 if (cifs_sb->mountdata == NULL) { 569 if (cifs_sb->mountdata == NULL) {
571 root = ERR_PTR(-ENOMEM); 570 root = ERR_PTR(-ENOMEM);
572 goto err_out; 571 goto out_super;
573 } 572 }
574 573
575 sb->s_flags = flags; 574 sb->s_flags = flags;
@@ -581,21 +580,23 @@ cifs_do_mount(struct file_system_type *fs_type,
581 flags & MS_SILENT ? 1 : 0); 580 flags & MS_SILENT ? 1 : 0);
582 if (rc) { 581 if (rc) {
583 root = ERR_PTR(rc); 582 root = ERR_PTR(rc);
584 goto err_out; 583 goto out_super;
585 } 584 }
586 585
587 sb->s_flags |= MS_ACTIVE; 586 sb->s_flags |= MS_ACTIVE;
588 587
589 root = dget(sb->s_root); 588 root = dget(sb->s_root);
590out: 589 goto out;
591 cifs_cleanup_volume_info(&volume_info);
592 return root;
593 590
594err_out: 591out_super:
595 kfree(cifs_sb->mountdata); 592 kfree(cifs_sb->mountdata);
593 deactivate_locked_super(sb);
594
595out_cifs_sb:
596 unload_nls(cifs_sb->local_nls); 596 unload_nls(cifs_sb->local_nls);
597 kfree(cifs_sb); 597 kfree(cifs_sb);
598 deactivate_locked_super(sb); 598
599out:
599 cifs_cleanup_volume_info(&volume_info); 600 cifs_cleanup_volume_info(&volume_info);
600 return root; 601 return root;
601} 602}