mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Colin Leroy <colin@colino.net>
To: Roman Zippel <zippel@linux-m68k.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@osdl.org>
Subject: [PATCH] hfsplus: don't leak sb->s_fs_info and don't oops on bad filesystem
Date: Tue, 26 Apr 2005 10:06:36 +0200	[thread overview]
Message-ID: <20050426100636.2bda6939@colin.toulouse> (raw)

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)

             reply	other threads:[~2005-04-26  8:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-26  8:06 Colin Leroy [this message]
2005-04-26 12:27 ` Roman Zippel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050426100636.2bda6939@colin.toulouse \
    --to=colin@colino.net \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zippel@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®