Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

exofs_mount(): fix leaks on failure exits

... and don't abuse mount_nodev(), while we are at it.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Reviewed-by: David Howells <dhowells@redhat.com>

Al Viro 26cb5a32 65102238

+29 -8
+29 -8
fs/exofs/super.c
··· 705 705 /* 706 706 * Read the superblock from the OSD and fill in the fields 707 707 */ 708 - static int exofs_fill_super(struct super_block *sb, void *data, int silent) 708 + static int exofs_fill_super(struct super_block *sb, 709 + struct exofs_mountopt *opts, 710 + struct exofs_sb_info *sbi, 711 + int silent) 709 712 { 710 713 struct inode *root; 711 - struct exofs_mountopt *opts = data; 712 - struct exofs_sb_info *sbi; /*extended info */ 713 714 struct osd_dev *od; /* Master device */ 714 715 struct exofs_fscb fscb; /*on-disk superblock info */ 715 716 struct ore_comp comp; 716 717 unsigned table_count; 717 718 int ret; 718 - 719 - sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); 720 - if (!sbi) 721 - return -ENOMEM; 722 719 723 720 /* use mount options to fill superblock */ 724 721 if (opts->is_osdname) { ··· 860 863 int flags, const char *dev_name, 861 864 void *data) 862 865 { 866 + struct super_block *s; 863 867 struct exofs_mountopt opts; 868 + struct exofs_sb_info *sbi; 864 869 int ret; 865 870 866 871 ret = parse_options(data, &opts); ··· 871 872 return ERR_PTR(ret); 872 873 } 873 874 875 + sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); 876 + if (!sbi) { 877 + kfree(opts.dev_name); 878 + return ERR_PTR(-ENOMEM); 879 + } 880 + 881 + s = sget(type, NULL, set_anon_super, flags, NULL); 882 + 883 + if (IS_ERR(s)) { 884 + kfree(opts.dev_name); 885 + kfree(sbi); 886 + return ERR_CAST(s); 887 + } 888 + 874 889 if (!opts.dev_name) 875 890 opts.dev_name = dev_name; 876 - return mount_nodev(type, flags, &opts, exofs_fill_super); 891 + 892 + 893 + ret = exofs_fill_super(s, &opts, sbi, flags & SB_SILENT ? 1 : 0); 894 + if (ret) { 895 + deactivate_locked_super(s); 896 + return ERR_PTR(ret); 897 + } 898 + s->s_flags |= SB_ACTIVE; 899 + return dget(s->s_root); 877 900 } 878 901 879 902 /*