Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=8af5e2eb3cc4450ffba9496c875beac41bf4f4f8
Commit:     8af5e2eb3cc4450ffba9496c875beac41bf4f4f8
Parent:     b446b60e4eb5e5457120c4728ada871b1209c1d0
Author:     KAMEZAWA Hiroyuki <[EMAIL PROTECTED]>
AuthorDate: Tue Feb 20 13:57:49 2007 -0800
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Tue Feb 20 17:10:13 2007 -0800

    [PATCH] fix mempolicy's check on a system with memory-less-node
    
    bind_zonelist() can create zero-length zonelist if there is a
    memory-less-node.  This patch checks the length of zonelist.  If length is
    0, returns -EINVAL.
    
    tested on ia64/NUMA with memory-less-node.
    
    Signed-off-by: KAMEZAWA Hiroyuki <[EMAIL PROTECTED]>
    Acked-by: Andi Kleen <[EMAIL PROTECTED]>
    Cc: Christoph Lameter <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 mm/mempolicy.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 259a706..cf2a538 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -144,7 +144,7 @@ static struct zonelist *bind_zonelist(nodemask_t *nodes)
        max++;                  /* space for zlcache_ptr (see mmzone.h) */
        zl = kmalloc(sizeof(struct zone *) * max, GFP_KERNEL);
        if (!zl)
-               return NULL;
+               return ERR_PTR(-ENOMEM);
        zl->zlcache_ptr = NULL;
        num = 0;
        /* First put in the highest zones from all nodes, then all the next 
@@ -162,6 +162,10 @@ static struct zonelist *bind_zonelist(nodemask_t *nodes)
                        break;
                k--;
        }
+       if (num == 0) {
+               kfree(zl);
+               return ERR_PTR(-EINVAL);
+       }
        zl->zones[num] = NULL;
        return zl;
 }
@@ -193,9 +197,10 @@ static struct mempolicy *mpol_new(int mode, nodemask_t 
*nodes)
                break;
        case MPOL_BIND:
                policy->v.zonelist = bind_zonelist(nodes);
-               if (policy->v.zonelist == NULL) {
+               if (IS_ERR(policy->v.zonelist)) {
+                       void *error_code = policy->v.zonelist;
                        kmem_cache_free(policy_cache, policy);
-                       return ERR_PTR(-ENOMEM);
+                       return error_code;
                }
                break;
        }
@@ -1667,7 +1672,7 @@ void mpol_rebind_policy(struct mempolicy *pol, const 
nodemask_t *newmask)
                 * then zonelist_policy() will "FALL THROUGH" to MPOL_DEFAULT.
                 */
 
-               if (zonelist) {
+               if (!IS_ERR(zonelist)) {
                        /* Good - got mem - substitute new zonelist */
                        kfree(pol->v.zonelist);
                        pol->v.zonelist = zonelist;
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to