Re: shmem_fill_super(): WARNING: kmemcheck: Caught 32-bit readfrom uninitialized memory

From: Cyrill Gorcunov
Date: Sun Sep 20 2009 - 14:04:35 EST


[Ingo Molnar - Sun, Sep 20, 2009 at 07:58:03PM +0200]
...
|
| > [ 0.408000] initcall init_mmap_min_addr+0x0/0x10 returned 0 after 0 usecs
| >
| > Reported-by: Ingo Molnar <mingo@xxxxxxx>
| > Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxxxxxx>
| > ---
| > mm/shmem.c | 5 +----
| > 1 files changed, 1 insertions(+), 4 deletions(-)
| >
| > diff --git a/mm/shmem.c b/mm/shmem.c
| > index d713239..a8f54f3 100644
| > --- a/mm/shmem.c
| > +++ b/mm/shmem.c
| > @@ -2307,17 +2307,14 @@ static int shmem_fill_super(struct super_block *sb,
| > int err = -ENOMEM;
| >
| > /* Round up to L1_CACHE_BYTES to resist false sharing */
| > - sbinfo = kmalloc(max((int)sizeof(struct shmem_sb_info),
| > + sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
| > L1_CACHE_BYTES), GFP_KERNEL);
| > if (!sbinfo)
| > return -ENOMEM;
| >
| > - sbinfo->max_blocks = 0;
| > - sbinfo->max_inodes = 0;
| > sbinfo->mode = S_IRWXUGO | S_ISVTX;
| > sbinfo->uid = current_fsuid();
| > sbinfo->gid = current_fsgid();
| > - sbinfo->mpol = NULL;
| > sb->s_fs_info = sbinfo;
|
| That looks like a step forward even without kmemcheck considered, right?
|
| Ingo

Yeah, and we save a few cpu cycles as well :)

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