* [PATCH] firmware, memmap: fix firmware_map_entry leak
@ 2013-04-15 5:48 Yasuaki Ishimatsu
2013-04-15 7:04 ` Wanpeng Li
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Yasuaki Ishimatsu @ 2013-04-15 5:48 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, linux-mm, wency, tangchen, toshi.kani
When hot removing a memory, a firmware_map_entry which has memory range
of the memory is released by release_firmware_map_entry(). If the entry
is allocated by bootmem, release_firmware_map_entry() adds the entry to
map_entires_bootmem list when firmware_map_find_entry() finds the entry
from map_entries list. But firmware_map_find_entry never find the entry
sicne map_entires list does not have the entry. So the entry just leaks.
Here are steps of leaking firmware_map_entry:
firmware_map_remove()
-> firmware_map_find_entry()
Find released entry from map_entries list
-> firmware_map_remove_entry()
Delete the entry from map_entries list
-> remove_sysfs_fw_map_entry()
...
-> release_firmware_map_entry()
-> firmware_map_find_entry()
Find the entry from map_entries list but the entry has been
deleted from map_entries list. So the entry is not added
to map_entries_bootmem. Thus the entry leaks
release_firmware_map_entry() should not call firmware_map_find_entry()
since releaed entry has been deleted from map_entries list.
So the patch delete firmware_map_find_entry() from releae_firmware_map_entry()
Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
---
drivers/firmware/memmap.c | 9 +++------
1 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c
index 0b5b5f6..e2e04b0 100644
--- a/drivers/firmware/memmap.c
+++ b/drivers/firmware/memmap.c
@@ -114,12 +114,9 @@ static void __meminit release_firmware_map_entry(struct kobject *kobj)
* map_entries_bootmem here, and deleted from &map_entries in
* firmware_map_remove_entry().
*/
- if (firmware_map_find_entry(entry->start, entry->end,
- entry->type)) {
- spin_lock(&map_entries_bootmem_lock);
- list_add(&entry->list, &map_entries_bootmem);
- spin_unlock(&map_entries_bootmem_lock);
- }
+ spin_lock(&map_entries_bootmem_lock);
+ list_add(&entry->list, &map_entries_bootmem);
+ spin_unlock(&map_entries_bootmem_lock);
return;
}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] firmware, memmap: fix firmware_map_entry leak
2013-04-15 5:48 [PATCH] firmware, memmap: fix firmware_map_entry leak Yasuaki Ishimatsu
2013-04-15 7:04 ` Wanpeng Li
@ 2013-04-15 7:04 ` Wanpeng Li
2013-04-15 7:24 ` Yasuaki Ishimatsu
2013-04-15 9:03 ` Tang Chen
2013-04-15 21:00 ` Toshi Kani
3 siblings, 1 reply; 8+ messages in thread
From: Wanpeng Li @ 2013-04-15 7:04 UTC (permalink / raw)
To: Yasuaki Ishimatsu
Cc: akpm, linux-kernel, linux-mm, wency, tangchen, toshi.kani
On Mon, Apr 15, 2013 at 02:48:17PM +0900, Yasuaki Ishimatsu wrote:
>When hot removing a memory, a firmware_map_entry which has memory range
>of the memory is released by release_firmware_map_entry(). If the entry
>is allocated by bootmem, release_firmware_map_entry() adds the entry to
>map_entires_bootmem list when firmware_map_find_entry() finds the entry
>from map_entries list. But firmware_map_find_entry never find the entry
>sicne map_entires list does not have the entry. So the entry just leaks.
>
>Here are steps of leaking firmware_map_entry:
>firmware_map_remove()
>-> firmware_map_find_entry()
> Find released entry from map_entries list
>-> firmware_map_remove_entry()
> Delete the entry from map_entries list
>-> remove_sysfs_fw_map_entry()
> ...
> -> release_firmware_map_entry()
> -> firmware_map_find_entry()
> Find the entry from map_entries list but the entry has been
> deleted from map_entries list. So the entry is not added
> to map_entries_bootmem. Thus the entry leaks
>
>release_firmware_map_entry() should not call firmware_map_find_entry()
>since releaed entry has been deleted from map_entries list.
>So the patch delete firmware_map_find_entry() from releae_firmware_map_entry()
>
Reviewed-by: Wanpeng Li <liwanp@linux.vnet.ibm.com>
>Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
>---
> drivers/firmware/memmap.c | 9 +++------
> 1 files changed, 3 insertions(+), 6 deletions(-)
>
>diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c
>index 0b5b5f6..e2e04b0 100644
>--- a/drivers/firmware/memmap.c
>+++ b/drivers/firmware/memmap.c
>@@ -114,12 +114,9 @@ static void __meminit release_firmware_map_entry(struct kobject *kobj)
> * map_entries_bootmem here, and deleted from &map_entries in
> * firmware_map_remove_entry().
> */
>- if (firmware_map_find_entry(entry->start, entry->end,
>- entry->type)) {
>- spin_lock(&map_entries_bootmem_lock);
>- list_add(&entry->list, &map_entries_bootmem);
>- spin_unlock(&map_entries_bootmem_lock);
>- }
>+ spin_lock(&map_entries_bootmem_lock);
>+ list_add(&entry->list, &map_entries_bootmem);
>+ spin_unlock(&map_entries_bootmem_lock);
>
> return;
> }
>
>--
>To unsubscribe, send a message with 'unsubscribe linux-mm' in
>the body to majordomo@kvack.org. For more info on Linux MM,
>see: http://www.linux-mm.org/ .
>Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] firmware, memmap: fix firmware_map_entry leak
2013-04-15 5:48 [PATCH] firmware, memmap: fix firmware_map_entry leak Yasuaki Ishimatsu
@ 2013-04-15 7:04 ` Wanpeng Li
2013-04-15 7:04 ` Wanpeng Li
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Wanpeng Li @ 2013-04-15 7:04 UTC (permalink / raw)
To: Yasuaki Ishimatsu
Cc: akpm, linux-kernel, linux-mm, wency, tangchen, toshi.kani
On Mon, Apr 15, 2013 at 02:48:17PM +0900, Yasuaki Ishimatsu wrote:
>When hot removing a memory, a firmware_map_entry which has memory range
>of the memory is released by release_firmware_map_entry(). If the entry
>is allocated by bootmem, release_firmware_map_entry() adds the entry to
>map_entires_bootmem list when firmware_map_find_entry() finds the entry
>from map_entries list. But firmware_map_find_entry never find the entry
>sicne map_entires list does not have the entry. So the entry just leaks.
>
>Here are steps of leaking firmware_map_entry:
>firmware_map_remove()
>-> firmware_map_find_entry()
> Find released entry from map_entries list
>-> firmware_map_remove_entry()
> Delete the entry from map_entries list
>-> remove_sysfs_fw_map_entry()
> ...
> -> release_firmware_map_entry()
> -> firmware_map_find_entry()
> Find the entry from map_entries list but the entry has been
> deleted from map_entries list. So the entry is not added
> to map_entries_bootmem. Thus the entry leaks
>
>release_firmware_map_entry() should not call firmware_map_find_entry()
>since releaed entry has been deleted from map_entries list.
>So the patch delete firmware_map_find_entry() from releae_firmware_map_entry()
>
Reviewed-by: Wanpeng Li <liwanp@linux.vnet.ibm.com>
>Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
>---
> drivers/firmware/memmap.c | 9 +++------
> 1 files changed, 3 insertions(+), 6 deletions(-)
>
>diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c
>index 0b5b5f6..e2e04b0 100644
>--- a/drivers/firmware/memmap.c
>+++ b/drivers/firmware/memmap.c
>@@ -114,12 +114,9 @@ static void __meminit release_firmware_map_entry(struct kobject *kobj)
> * map_entries_bootmem here, and deleted from &map_entries in
> * firmware_map_remove_entry().
> */
>- if (firmware_map_find_entry(entry->start, entry->end,
>- entry->type)) {
>- spin_lock(&map_entries_bootmem_lock);
>- list_add(&entry->list, &map_entries_bootmem);
>- spin_unlock(&map_entries_bootmem_lock);
>- }
>+ spin_lock(&map_entries_bootmem_lock);
>+ list_add(&entry->list, &map_entries_bootmem);
>+ spin_unlock(&map_entries_bootmem_lock);
>
> return;
> }
>
>--
>To unsubscribe, send a message with 'unsubscribe linux-mm' in
>the body to majordomo@kvack.org. For more info on Linux MM,
>see: http://www.linux-mm.org/ .
>Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] firmware, memmap: fix firmware_map_entry leak
2013-04-15 7:04 ` Wanpeng Li
@ 2013-04-15 7:24 ` Yasuaki Ishimatsu
0 siblings, 0 replies; 8+ messages in thread
From: Yasuaki Ishimatsu @ 2013-04-15 7:24 UTC (permalink / raw)
To: Wanpeng Li; +Cc: akpm, linux-kernel, linux-mm, wency, tangchen, toshi.kani
2013/04/15 16:04, Wanpeng Li wrote:
> On Mon, Apr 15, 2013 at 02:48:17PM +0900, Yasuaki Ishimatsu wrote:
>> When hot removing a memory, a firmware_map_entry which has memory range
>> of the memory is released by release_firmware_map_entry(). If the entry
>> is allocated by bootmem, release_firmware_map_entry() adds the entry to
>> map_entires_bootmem list when firmware_map_find_entry() finds the entry
>>from map_entries list. But firmware_map_find_entry never find the entry
>> sicne map_entires list does not have the entry. So the entry just leaks.
>>
>> Here are steps of leaking firmware_map_entry:
>> firmware_map_remove()
>> -> firmware_map_find_entry()
>> Find released entry from map_entries list
>> -> firmware_map_remove_entry()
>> Delete the entry from map_entries list
>> -> remove_sysfs_fw_map_entry()
>> ...
>> -> release_firmware_map_entry()
>> -> firmware_map_find_entry()
>> Find the entry from map_entries list but the entry has been
>> deleted from map_entries list. So the entry is not added
>> to map_entries_bootmem. Thus the entry leaks
>>
>> release_firmware_map_entry() should not call firmware_map_find_entry()
>> since releaed entry has been deleted from map_entries list.
>> So the patch delete firmware_map_find_entry() from releae_firmware_map_entry()
>>
>
> Reviewed-by: Wanpeng Li <liwanp@linux.vnet.ibm.com>
Thank you for your review.
Thanks,
Yasuaki Ishimatsu
>
>> Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
>> ---
>> drivers/firmware/memmap.c | 9 +++------
>> 1 files changed, 3 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c
>> index 0b5b5f6..e2e04b0 100644
>> --- a/drivers/firmware/memmap.c
>> +++ b/drivers/firmware/memmap.c
>> @@ -114,12 +114,9 @@ static void __meminit release_firmware_map_entry(struct kobject *kobj)
>> * map_entries_bootmem here, and deleted from &map_entries in
>> * firmware_map_remove_entry().
>> */
>> - if (firmware_map_find_entry(entry->start, entry->end,
>> - entry->type)) {
>> - spin_lock(&map_entries_bootmem_lock);
>> - list_add(&entry->list, &map_entries_bootmem);
>> - spin_unlock(&map_entries_bootmem_lock);
>> - }
>> + spin_lock(&map_entries_bootmem_lock);
>> + list_add(&entry->list, &map_entries_bootmem);
>> + spin_unlock(&map_entries_bootmem_lock);
>>
>> return;
>> }
>>
>> --
>> To unsubscribe, send a message with 'unsubscribe linux-mm' in
>> the body to majordomo@kvack.org. For more info on Linux MM,
>> see: http://www.linux-mm.org/ .
>> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] firmware, memmap: fix firmware_map_entry leak
2013-04-15 5:48 [PATCH] firmware, memmap: fix firmware_map_entry leak Yasuaki Ishimatsu
2013-04-15 7:04 ` Wanpeng Li
2013-04-15 7:04 ` Wanpeng Li
@ 2013-04-15 9:03 ` Tang Chen
2013-04-15 23:37 ` Yasuaki Ishimatsu
2013-04-15 21:00 ` Toshi Kani
3 siblings, 1 reply; 8+ messages in thread
From: Tang Chen @ 2013-04-15 9:03 UTC (permalink / raw)
To: Yasuaki Ishimatsu; +Cc: akpm, linux-kernel, linux-mm, wency, toshi.kani
Reviewed-by: Tang Chen <tangchen@cn.fujitsu.com>
Thanks. :)
On 04/15/2013 01:48 PM, Yasuaki Ishimatsu wrote:
> When hot removing a memory, a firmware_map_entry which has memory range
> of the memory is released by release_firmware_map_entry(). If the entry
> is allocated by bootmem, release_firmware_map_entry() adds the entry to
> map_entires_bootmem list when firmware_map_find_entry() finds the entry
> from map_entries list. But firmware_map_find_entry never find the entry
> sicne map_entires list does not have the entry. So the entry just leaks.
>
> Here are steps of leaking firmware_map_entry:
> firmware_map_remove()
> -> firmware_map_find_entry()
> Find released entry from map_entries list
> -> firmware_map_remove_entry()
> Delete the entry from map_entries list
> -> remove_sysfs_fw_map_entry()
> ...
> -> release_firmware_map_entry()
> -> firmware_map_find_entry()
> Find the entry from map_entries list but the entry has been
> deleted from map_entries list. So the entry is not added
> to map_entries_bootmem. Thus the entry leaks
>
> release_firmware_map_entry() should not call firmware_map_find_entry()
> since releaed entry has been deleted from map_entries list.
> So the patch delete firmware_map_find_entry() from releae_firmware_map_entry()
>
> Signed-off-by: Yasuaki Ishimatsu<isimatu.yasuaki@jp.fujitsu.com>
> ---
> drivers/firmware/memmap.c | 9 +++------
> 1 files changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c
> index 0b5b5f6..e2e04b0 100644
> --- a/drivers/firmware/memmap.c
> +++ b/drivers/firmware/memmap.c
> @@ -114,12 +114,9 @@ static void __meminit release_firmware_map_entry(struct kobject *kobj)
> * map_entries_bootmem here, and deleted from&map_entries in
> * firmware_map_remove_entry().
> */
> - if (firmware_map_find_entry(entry->start, entry->end,
> - entry->type)) {
> - spin_lock(&map_entries_bootmem_lock);
> - list_add(&entry->list,&map_entries_bootmem);
> - spin_unlock(&map_entries_bootmem_lock);
> - }
> + spin_lock(&map_entries_bootmem_lock);
> + list_add(&entry->list,&map_entries_bootmem);
> + spin_unlock(&map_entries_bootmem_lock);
>
> return;
> }
>
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] firmware, memmap: fix firmware_map_entry leak
2013-04-15 5:48 [PATCH] firmware, memmap: fix firmware_map_entry leak Yasuaki Ishimatsu
` (2 preceding siblings ...)
2013-04-15 9:03 ` Tang Chen
@ 2013-04-15 21:00 ` Toshi Kani
2013-04-15 23:38 ` Yasuaki Ishimatsu
3 siblings, 1 reply; 8+ messages in thread
From: Toshi Kani @ 2013-04-15 21:00 UTC (permalink / raw)
To: Yasuaki Ishimatsu; +Cc: akpm, linux-kernel, linux-mm, wency, tangchen
On Mon, 2013-04-15 at 14:48 +0900, Yasuaki Ishimatsu wrote:
> When hot removing a memory, a firmware_map_entry which has memory range
> of the memory is released by release_firmware_map_entry(). If the entry
> is allocated by bootmem, release_firmware_map_entry() adds the entry to
> map_entires_bootmem list when firmware_map_find_entry() finds the entry
> from map_entries list. But firmware_map_find_entry never find the entry
> sicne map_entires list does not have the entry. So the entry just leaks.
>
> Here are steps of leaking firmware_map_entry:
> firmware_map_remove()
> -> firmware_map_find_entry()
> Find released entry from map_entries list
> -> firmware_map_remove_entry()
> Delete the entry from map_entries list
> -> remove_sysfs_fw_map_entry()
> ...
> -> release_firmware_map_entry()
> -> firmware_map_find_entry()
> Find the entry from map_entries list but the entry has been
> deleted from map_entries list. So the entry is not added
> to map_entries_bootmem. Thus the entry leaks
>
> release_firmware_map_entry() should not call firmware_map_find_entry()
> since releaed entry has been deleted from map_entries list.
> So the patch delete firmware_map_find_entry() from releae_firmware_map_entry()
>
> Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Acked-by: Toshi Kani <toshi.kani@hp.com>
Thanks,
-Toshi
> ---
> drivers/firmware/memmap.c | 9 +++------
> 1 files changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c
> index 0b5b5f6..e2e04b0 100644
> --- a/drivers/firmware/memmap.c
> +++ b/drivers/firmware/memmap.c
> @@ -114,12 +114,9 @@ static void __meminit release_firmware_map_entry(struct kobject *kobj)
> * map_entries_bootmem here, and deleted from &map_entries in
> * firmware_map_remove_entry().
> */
> - if (firmware_map_find_entry(entry->start, entry->end,
> - entry->type)) {
> - spin_lock(&map_entries_bootmem_lock);
> - list_add(&entry->list, &map_entries_bootmem);
> - spin_unlock(&map_entries_bootmem_lock);
> - }
> + spin_lock(&map_entries_bootmem_lock);
> + list_add(&entry->list, &map_entries_bootmem);
> + spin_unlock(&map_entries_bootmem_lock);
>
> return;
> }
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] firmware, memmap: fix firmware_map_entry leak
2013-04-15 9:03 ` Tang Chen
@ 2013-04-15 23:37 ` Yasuaki Ishimatsu
0 siblings, 0 replies; 8+ messages in thread
From: Yasuaki Ishimatsu @ 2013-04-15 23:37 UTC (permalink / raw)
To: Tang Chen; +Cc: akpm, linux-kernel, linux-mm, wency, toshi.kani
2013/04/15 18:03, Tang Chen wrote:
>
> Reviewed-by: Tang Chen <tangchen@cn.fujitsu.com>
Thank you for your review.
Thanks,
Yasuaki Ishimatsu
>
> Thanks. :)
>
> On 04/15/2013 01:48 PM, Yasuaki Ishimatsu wrote:
>> When hot removing a memory, a firmware_map_entry which has memory range
>> of the memory is released by release_firmware_map_entry(). If the entry
>> is allocated by bootmem, release_firmware_map_entry() adds the entry to
>> map_entires_bootmem list when firmware_map_find_entry() finds the entry
>> from map_entries list. But firmware_map_find_entry never find the entry
>> sicne map_entires list does not have the entry. So the entry just leaks.
>>
>> Here are steps of leaking firmware_map_entry:
>> firmware_map_remove()
>> -> firmware_map_find_entry()
>> Find released entry from map_entries list
>> -> firmware_map_remove_entry()
>> Delete the entry from map_entries list
>> -> remove_sysfs_fw_map_entry()
>> ...
>> -> release_firmware_map_entry()
>> -> firmware_map_find_entry()
>> Find the entry from map_entries list but the entry has been
>> deleted from map_entries list. So the entry is not added
>> to map_entries_bootmem. Thus the entry leaks
>>
>> release_firmware_map_entry() should not call firmware_map_find_entry()
>> since releaed entry has been deleted from map_entries list.
>> So the patch delete firmware_map_find_entry() from releae_firmware_map_entry()
>>
>> Signed-off-by: Yasuaki Ishimatsu<isimatu.yasuaki@jp.fujitsu.com>
>> ---
>> drivers/firmware/memmap.c | 9 +++------
>> 1 files changed, 3 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c
>> index 0b5b5f6..e2e04b0 100644
>> --- a/drivers/firmware/memmap.c
>> +++ b/drivers/firmware/memmap.c
>> @@ -114,12 +114,9 @@ static void __meminit release_firmware_map_entry(struct kobject *kobj)
>> * map_entries_bootmem here, and deleted from&map_entries in
>> * firmware_map_remove_entry().
>> */
>> - if (firmware_map_find_entry(entry->start, entry->end,
>> - entry->type)) {
>> - spin_lock(&map_entries_bootmem_lock);
>> - list_add(&entry->list,&map_entries_bootmem);
>> - spin_unlock(&map_entries_bootmem_lock);
>> - }
>> + spin_lock(&map_entries_bootmem_lock);
>> + list_add(&entry->list,&map_entries_bootmem);
>> + spin_unlock(&map_entries_bootmem_lock);
>>
>> return;
>> }
>>
>>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] firmware, memmap: fix firmware_map_entry leak
2013-04-15 21:00 ` Toshi Kani
@ 2013-04-15 23:38 ` Yasuaki Ishimatsu
0 siblings, 0 replies; 8+ messages in thread
From: Yasuaki Ishimatsu @ 2013-04-15 23:38 UTC (permalink / raw)
To: Toshi Kani; +Cc: akpm, linux-kernel, linux-mm, wency, tangchen
2013/04/16 6:00, Toshi Kani wrote:
> On Mon, 2013-04-15 at 14:48 +0900, Yasuaki Ishimatsu wrote:
>> When hot removing a memory, a firmware_map_entry which has memory range
>> of the memory is released by release_firmware_map_entry(). If the entry
>> is allocated by bootmem, release_firmware_map_entry() adds the entry to
>> map_entires_bootmem list when firmware_map_find_entry() finds the entry
>> from map_entries list. But firmware_map_find_entry never find the entry
>> sicne map_entires list does not have the entry. So the entry just leaks.
>>
>> Here are steps of leaking firmware_map_entry:
>> firmware_map_remove()
>> -> firmware_map_find_entry()
>> Find released entry from map_entries list
>> -> firmware_map_remove_entry()
>> Delete the entry from map_entries list
>> -> remove_sysfs_fw_map_entry()
>> ...
>> -> release_firmware_map_entry()
>> -> firmware_map_find_entry()
>> Find the entry from map_entries list but the entry has been
>> deleted from map_entries list. So the entry is not added
>> to map_entries_bootmem. Thus the entry leaks
>>
>> release_firmware_map_entry() should not call firmware_map_find_entry()
>> since releaed entry has been deleted from map_entries list.
>> So the patch delete firmware_map_find_entry() from releae_firmware_map_entry()
>>
>> Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
>
> Acked-by: Toshi Kani <toshi.kani@hp.com>
Thank you for your review.
Thanks,
Yasuaki Ishimatsu
>
> Thanks,
> -Toshi
>
>
>> ---
>> drivers/firmware/memmap.c | 9 +++------
>> 1 files changed, 3 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c
>> index 0b5b5f6..e2e04b0 100644
>> --- a/drivers/firmware/memmap.c
>> +++ b/drivers/firmware/memmap.c
>> @@ -114,12 +114,9 @@ static void __meminit release_firmware_map_entry(struct kobject *kobj)
>> * map_entries_bootmem here, and deleted from &map_entries in
>> * firmware_map_remove_entry().
>> */
>> - if (firmware_map_find_entry(entry->start, entry->end,
>> - entry->type)) {
>> - spin_lock(&map_entries_bootmem_lock);
>> - list_add(&entry->list, &map_entries_bootmem);
>> - spin_unlock(&map_entries_bootmem_lock);
>> - }
>> + spin_lock(&map_entries_bootmem_lock);
>> + list_add(&entry->list, &map_entries_bootmem);
>> + spin_unlock(&map_entries_bootmem_lock);
>>
>> return;
>> }
>>
>
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-04-15 23:38 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-15 5:48 [PATCH] firmware, memmap: fix firmware_map_entry leak Yasuaki Ishimatsu
2013-04-15 7:04 ` Wanpeng Li
2013-04-15 7:04 ` Wanpeng Li
2013-04-15 7:24 ` Yasuaki Ishimatsu
2013-04-15 9:03 ` Tang Chen
2013-04-15 23:37 ` Yasuaki Ishimatsu
2013-04-15 21:00 ` Toshi Kani
2013-04-15 23:38 ` Yasuaki Ishimatsu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox