diff options
author | Sachin Prabhu <sprabhu@redhat.com> | 2016-07-29 17:38:19 -0400 |
---|---|---|
committer | Steve French <smfrench@gmail.com> | 2016-09-10 00:58:06 -0400 |
commit | 4214ebf4654798309364d0c678b799e402f38288 (patch) | |
tree | 489695c51262266b0d75fd2c7d3343ce4a2d48fc /fs/cifs/cifsfs.c | |
parent | bd0b841fee49de421f615cc173ccff063303672f (diff) |
Fix memory leaks in cifs_do_mount()
Fix memory leaks introduced by the patch
fs/cifs: make share unaccessible at root level mountable
Also move allocation of cifs_sb->prepath to cifs_setup_cifs_sb().
Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
Tested-by: Aurelien Aptel <aaptel@suse.com>
Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs/cifsfs.c')
-rw-r--r-- | fs/cifs/cifsfs.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 6bbec5e784cd..cc9cdab52dab 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c | |||
@@ -686,26 +686,22 @@ cifs_do_mount(struct file_system_type *fs_type, | |||
686 | cifs_sb->mountdata = kstrndup(data, PAGE_SIZE, GFP_KERNEL); | 686 | cifs_sb->mountdata = kstrndup(data, PAGE_SIZE, GFP_KERNEL); |
687 | if (cifs_sb->mountdata == NULL) { | 687 | if (cifs_sb->mountdata == NULL) { |
688 | root = ERR_PTR(-ENOMEM); | 688 | root = ERR_PTR(-ENOMEM); |
689 | goto out_cifs_sb; | 689 | goto out_free; |
690 | } | 690 | } |
691 | 691 | ||
692 | if (volume_info->prepath) { | 692 | rc = cifs_setup_cifs_sb(volume_info, cifs_sb); |
693 | cifs_sb->prepath = kstrdup(volume_info->prepath, GFP_KERNEL); | 693 | if (rc) { |
694 | if (cifs_sb->prepath == NULL) { | 694 | root = ERR_PTR(rc); |
695 | root = ERR_PTR(-ENOMEM); | 695 | goto out_free; |
696 | goto out_cifs_sb; | ||
697 | } | ||
698 | } | 696 | } |
699 | 697 | ||
700 | cifs_setup_cifs_sb(volume_info, cifs_sb); | ||
701 | |||
702 | rc = cifs_mount(cifs_sb, volume_info); | 698 | rc = cifs_mount(cifs_sb, volume_info); |
703 | if (rc) { | 699 | if (rc) { |
704 | if (!(flags & MS_SILENT)) | 700 | if (!(flags & MS_SILENT)) |
705 | cifs_dbg(VFS, "cifs_mount failed w/return code = %d\n", | 701 | cifs_dbg(VFS, "cifs_mount failed w/return code = %d\n", |
706 | rc); | 702 | rc); |
707 | root = ERR_PTR(rc); | 703 | root = ERR_PTR(rc); |
708 | goto out_mountdata; | 704 | goto out_free; |
709 | } | 705 | } |
710 | 706 | ||
711 | mnt_data.vol = volume_info; | 707 | mnt_data.vol = volume_info; |
@@ -752,9 +748,9 @@ out: | |||
752 | cifs_cleanup_volume_info(volume_info); | 748 | cifs_cleanup_volume_info(volume_info); |
753 | return root; | 749 | return root; |
754 | 750 | ||
755 | out_mountdata: | 751 | out_free: |
752 | kfree(cifs_sb->prepath); | ||
756 | kfree(cifs_sb->mountdata); | 753 | kfree(cifs_sb->mountdata); |
757 | out_cifs_sb: | ||
758 | kfree(cifs_sb); | 754 | kfree(cifs_sb); |
759 | out_nls: | 755 | out_nls: |
760 | unload_nls(volume_info->local_nls); | 756 | unload_nls(volume_info->local_nls); |