lkml.org 
[lkml]   [2005]   [Apr]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] hfsplus: don't oops on bad FS
On Mon, 25 Apr 2005 22:26:26 +0200 (CEST)
Roman Zippel <zippel@linux-m68k.org> wrote:

Hi,

> > > Actually it looks like we are always leaking it, so actually
> > > hfsplus_put_super() needs fixing, could you add the check and
> > > kfree there and do the same fix for hfs?
> >
> > Mmh, right. Here's an updated version that fixes it too.
>
> Don't change hfsplus_fill_super, add a "if (!sb->s_fs_info) return;"
> to hfsplus_put_super

I don't get it. I do have to change hfsplus_fill_super to free
sb->s_fs_info, don't I? If I just nullify it there, there will be a
leak, and if I don't, put_super won't know it shouldn't do anything.

This try brings in less changes, but I don't see how to do even less:
(pseudo-patch that won't apply, just to know):
--- fs/hfsplus/super.c.orig 2005-04-25 21:56:56.000000000 +0200
+++ fs/hfsplus/super.c 2005-04-26 08:57:22.000000000 +0200
@@ -207,6 +207,9 @@ static void hfsplus_write_super(struct s

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;
@@ -226,6 +229,9 @@ static void hfsplus_put_super(struct sup
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;
}

static int hfsplus_statfs(struct super_block *sb, struct kstatfs *buf)
@@ -427,6 +433,9 @@ out:
return 0;

cleanup:
+ kfree(sb->s_fs_info);
+ sb->s_fs_info = NULL;
+
hfsplus_put_super(sb);
if (nls)
unload_nls(nls);
What do you think?

Thanks,
--
Colin
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-04-26 09:07    [W:0.063 / U:0.256 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site