• Andrew Morton's avatar
    [PATCH] ext2_fill_super breakage · 7048ea4d
    Andrew Morton authored
    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.
    7048ea4d
inode.c 6.04 KB