Commit 71ffd957 authored by Christoph Hellwig's avatar Christoph Hellwig

[XFS] Fix unchecked kmalloc() in pagebuf

SGI Modid: 2.5.x-xfs:slinx:132859a
parent cebce9d8
...@@ -245,19 +245,27 @@ typedef struct a_list { ...@@ -245,19 +245,27 @@ typedef struct a_list {
STATIC a_list_t *as_free_head; STATIC a_list_t *as_free_head;
STATIC int as_list_len; STATIC int as_list_len;
/*
* Try to batch vunmaps because they are costly.
*/
STATIC void STATIC void
free_address( free_address(
void *addr) void *addr)
{ {
a_list_t *aentry; a_list_t *aentry;
spin_lock(&as_lock);
aentry = kmalloc(sizeof(a_list_t), GFP_ATOMIC); aentry = kmalloc(sizeof(a_list_t), GFP_ATOMIC);
aentry->next = as_free_head; if (aentry) {
aentry->vm_addr = addr; spin_lock(&as_lock);
as_free_head = aentry; aentry->next = as_free_head;
as_list_len++; aentry->vm_addr = addr;
spin_unlock(&as_lock); as_free_head = aentry;
as_list_len++;
spin_unlock(&as_lock);
} else {
vunmap(addr);
}
} }
STATIC void STATIC void
...@@ -265,7 +273,8 @@ purge_addresses(void) ...@@ -265,7 +273,8 @@ purge_addresses(void)
{ {
a_list_t *aentry, *old; a_list_t *aentry, *old;
if (as_free_head == NULL) return; if (as_free_head == NULL)
return;
spin_lock(&as_lock); spin_lock(&as_lock);
aentry = as_free_head; aentry = as_free_head;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment