[PATCH] ext2_fill_super breakage
authorAndrew Morton <akpm@zip.com.au>
Tue, 2 Apr 2002 03:44:16 +0000 (19:44 -0800)
committerLinus Torvalds <torvalds@home.transmeta.com>
Tue, 2 Apr 2002 03:44:16 +0000 (19:44 -0800)
commit7048ea4d1541ff1d36920b1c0c90bd11f5ee1a9f
tree6689b4660de7bc6788e64acf315c832d1669746f
parent5be8243bd92f67431530bf323d96030325dc2697
[PATCH] ext2_fill_super breakage

In 2.5.7 there is a thinko in the allocation and initialisation
of the fs-private superblock for ext2.  It's passing the wrong type
to the sizeof operator (which of course gives the wrong size)
when allocating and clearing the memory.

Lesson for the day: this is one of the reasons why this idiom:

some_type *p;

p = malloc(sizeof(*p));
...
memset(p, 0, sizeof(*p));

is preferable to

some_type *p;

p = malloc(sizeof(some_type));
...
memset(p, 0, sizeof(some_type));

I checked the other filesystems.  They're OK (but idiomatically
impure).  I've added a couple of defensive memsets where
they were missing.
fs/autofs/inode.c
fs/devpts/inode.c
fs/ext2/super.c