Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6d729e44 authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Al Viro
Browse files

fs: Make unload_nls() NULL pointer safe



Most call sites of unload_nls() do:
	if (nls)
		unload_nls(nls);

Check the pointer inside unload_nls() like we do in kfree() and
simplify the call sites.

Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Cc: Steve French <sfrench@us.ibm.com>
Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: Roman Zippel <zippel@linux-m68k.org>
Cc: Dave Kleikamp <shaggy@linux.vnet.ibm.com>
Cc: Petr Vandrovec <vandrove@vc.cvut.cz>
Cc: Anton Altaparmakov <aia21@cantab.net>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 4504230a
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -737,12 +737,7 @@ befs_put_super(struct super_block *sb)
{
	kfree(BEFS_SB(sb)->mount_opts.iocharset);
	BEFS_SB(sb)->mount_opts.iocharset = NULL;

	if (BEFS_SB(sb)->nls) {
	unload_nls(BEFS_SB(sb)->nls);
		BEFS_SB(sb)->nls = NULL;
	}

	kfree(sb->s_fs_info);
	sb->s_fs_info = NULL;
}
+1 −2
Original line number Diff line number Diff line
@@ -185,7 +185,6 @@ cifs_read_super(struct super_block *sb, void *data,
			cifs_sb->mountdata = NULL;
		}
#endif
		if (cifs_sb->local_nls)
		unload_nls(cifs_sb->local_nls);
		kfree(cifs_sb);
	}
+4 −12
Original line number Diff line number Diff line
@@ -470,19 +470,11 @@ static void fat_put_super(struct super_block *sb)

	iput(sbi->fat_inode);

	if (sbi->nls_disk) {
	unload_nls(sbi->nls_disk);
		sbi->nls_disk = NULL;
		sbi->options.codepage = fat_default_codepage;
	}
	if (sbi->nls_io) {
	unload_nls(sbi->nls_io);
		sbi->nls_io = NULL;
	}
	if (sbi->options.iocharset != fat_default_iocharset) {

	if (sbi->options.iocharset != fat_default_iocharset)
		kfree(sbi->options.iocharset);
		sbi->options.iocharset = fat_default_iocharset;
	}

	sb->s_fs_info = NULL;
	kfree(sbi);
+2 −4
Original line number Diff line number Diff line
@@ -344,9 +344,7 @@ void hfs_mdb_put(struct super_block *sb)
	brelse(HFS_SB(sb)->mdb_bh);
	brelse(HFS_SB(sb)->alt_mdb_bh);

	if (HFS_SB(sb)->nls_io)
	unload_nls(HFS_SB(sb)->nls_io);
	if (HFS_SB(sb)->nls_disk)
	unload_nls(HFS_SB(sb)->nls_disk);

	free_pages((unsigned long)HFS_SB(sb)->bitmap, PAGE_SIZE < 8192 ? 1 : 0);
+2 −4
Original line number Diff line number Diff line
@@ -229,7 +229,6 @@ static void hfsplus_put_super(struct super_block *sb)
	iput(HFSPLUS_SB(sb).alloc_file);
	iput(HFSPLUS_SB(sb).hidden_dir);
	brelse(HFSPLUS_SB(sb).s_vhbh);
	if (HFSPLUS_SB(sb).nls)
	unload_nls(HFSPLUS_SB(sb).nls);
	kfree(sb->s_fs_info);
	sb->s_fs_info = NULL;
@@ -464,7 +463,6 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)

cleanup:
	hfsplus_put_super(sb);
	if (nls)
	unload_nls(nls);
	return err;
}
Loading