mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] hfsplus: don't leak sb->s_fs_info and don't oops on bad filesystem
@ 2005-04-26  8:06 Colin Leroy
  2005-04-26 12:27 ` Roman Zippel
  0 siblings, 1 reply; 2+ messages in thread
From: Colin Leroy @ 2005-04-26  8:06 UTC (permalink / raw)
  To: Roman Zippel; +Cc: linux-kernel, Andrew Morton

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 <colin@colino.net>
--- 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)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-04-26 12:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-26  8:06 [PATCH] hfsplus: don't leak sb->s_fs_info and don't oops on bad filesystem Colin Leroy
2005-04-26 12:27 ` Roman Zippel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®