Skip to contentSkip to conversation

fs/binfmt_elf.c: fix a wrong free

PATCH RESEND New WANG Cong 1 participant 1 message May 6, 2008

Subsystems (2)
lore
Share & tools
lore

WANG Cong

author
#0 lore raw

PATCH RESEND 1/1 fs/binfmt_elf.c: fix a wrong free

In kmalloc failing path, we shouldn't free pointers in 'info', because the struct 'info' is uninitilized when kmalloc is called.

And when kmalloc returns NULL, it's needless to kfree it.

--

fs/binfmt_elf.c +3 -2
index f6d5a9d..357b503 100644
@@ -1900,7 +1900,7 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, un
 	/* alloc memory for large data structures: too large to be on stack */
 	elf = kmalloc(sizeof(*elf), GFP_KERNEL);
 	if (!elf)
-		goto cleanup;
+		goto out;
 	
 	segs = current->mm->map_count;
 #ifdef ELF_CORE_EXTRA_PHDRS
@@ -2034,8 +2034,9 @@ end_coredump:
 	set_fs(fs);
 
 cleanup:
-	kfree(elf);
 	free_note_info(&info);
+	kfree(elf);
+out:
 	return has_dumped;
 }