[PATCH] hfsplus: don't leak sb->s_fs_info and don't oops on bad filesystem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

This is the second attempt at fixing two bugs in hfsplus; this patch
fixes the leak of sb->s_fs_info, and also fixes an oops [1] when trying
to mount something that isn't hfsplus with hfsplus.

The first hunk is just a protection, the second one fixes the oops, and 
the third one fixes the leak.

[1] http://colino.net/tmp/hfsplus_oops.txt

Signed-off-by: Colin Leroy <[email protected]>
--- a/fs/hfsplus/super.c	2005-04-25 21:56:56.000000000 +0200
+++ b/fs/hfsplus/super.c	2005-04-26 09:56:49.000000000 +0200
@@ -207,9 +207,14 @@
 
 static void hfsplus_put_super(struct super_block *sb)
 {
+	if (!sb->s_fs_info)
+		return;
+
 	dprint(DBG_SUPER, "hfsplus_put_super\n");
 	if (!(sb->s_flags & MS_RDONLY)) {
 		struct hfsplus_vh *vhdr = HFSPLUS_SB(sb).s_vhdr;
+		if (!vhdr)
+			goto cleanup;
 
 		vhdr->modify_date = hfsp_now2mt();
 		vhdr->attributes |= cpu_to_be32(HFSPLUS_VOL_UNMNT);
@@ -226,6 +231,10 @@
 	brelse(HFSPLUS_SB(sb).s_vhbh);
 	if (HFSPLUS_SB(sb).nls)
 		unload_nls(HFSPLUS_SB(sb).nls);
+
+cleanup:
+	kfree(sb->s_fs_info);
+	sb->s_fs_info = NULL;
 }
 
 static int hfsplus_statfs(struct super_block *sb, struct kstatfs *buf)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux