Re: [PATCH] x86: Fix io_bitmap_ptr memory leak on copy_process()
From: Tadashi Abe
Date: Mon Feb 14 2011 - 04:27:34 EST
>>> 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
--
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/