Thread (7 messages) 7 messages, 2 authors, 2011-04-11

[Bug 30872] Calling kfree() for uninitialized pointer in ext4_mb_init_backend()

From: <hidden>
Date: 2011-03-14 14:23:32

https://bugzilla.kernel.org/show_bug.cgi?id=30872


Eric Sandeen [off-list ref] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sandeen@redhat.com



--- Comment #2 from Eric Sandeen <sandeen@redhat.com>  2011-03-14 14:23:29 ---
(In reply to comment #1)

...
quoted
If ext4_mb_add_groupinfo() fails for some reason (e.g. if memory allocation at
line 2296 fails), ext4_mb_init_backend() tries to call kfree() for each
element in sbi->s_group_info array, including the ones that have not been
initialized yet:

fs/ext4/mballoc.c:2414:
err_freebuddy:
   cachep = get_groupinfo_cache(sb->s_blocksize_bits);
   while (i-- > 0)
       kmem_cache_free(cachep, ext4_get_group_info(sb, i));
   i = num_meta_group_infos;
   while (i-- > 0)
literally understand, should be
while (--i >= 0)

Could you try with above?
Hm, that probably is the most direct fix.

I sent a patch here:
http://marc.info/?l=linux-ext4&m=129979820301087&w=2
which initializes all the pointers to NULL and only frees if they are non-NULL, 
which may be more foolproof, but might also be overkill.

-Eric

-- 
Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching the assignee of the bug.--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help