Messages in this thread | | | Date | Mon, 14 Feb 2011 18:27:20 +0900 | From | Tadashi Abe <> | Subject | Re: [PATCH] x86: Fix io_bitmap_ptr memory leak on copy_process() |
| |
>>> diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c >>> index b3feabc..290e98b 100644 >>> --- a/arch/x86/kernel/process.c >>> +++ b/arch/x86/kernel/process.c >>> @@ -122,6 +122,12 @@ void flush_thread(void) >>> clear_used_math(); >>> } >>> >>> +void free_thread_struct(struct task_struct *p) >>> +{ >>> + if (p->thread.io_bitmap_ptr) >>> + kfree(p->thread.io_bitmap_ptr); >> >> kfree(NULL) is perfectly legal, so the 'if' is not needed.
Thanks. agreed.
>> Why is this a new function? Why not simply call kfree() when needed.
io_bitmap_ptr is a x86 specific variable so I didn't think it should be in generic kernel codes (kernel/fork.c). I understand making a new function looks overkill though. Even if you call kfree() directly in kernel/fork.c, "#ifdef CONFIG_X86" is necessary anyway.
But I don't have any insistence on how to fix it and leave it to experts' choice.
Thanks -- Tadashi
| |