[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1317929306-18471-1-git-send-email-sjenning@linux.vnet.ibm.com>
Date: Thu, 6 Oct 2011 14:28:26 -0500
From: Seth Jennings <sjenning@...ux.vnet.ibm.com>
To: gregkh@...e.de
Cc: cascardo@...oscopio.com, dan.magenheimer@...cle.com,
rdunlap@...otime.net, devel@...verdev.osuosl.org,
linux-kernel@...r.kernel.org, dave@...ux.vnet.ibm.com,
rcj@...ux.vnet.ibm.com, brking@...ux.vnet.ibm.com,
ngupta@...are.org, Seth Jennings <sjenning@...ux.vnet.ibm.com>
Subject: [PATCH] staging: zcache: fix crash on cpu remove
In the case that a cpu is taken offline before zcache_do_preload() is
ever called on the cpu, the per-cpu zcache_preloads structure will
be uninitialized. In the CPU_DEAD case for zcache_cpu_notifier(),
kp->obj is not checked before calling kmem_cache_free() on it.
If it is NULL, a crash results.
This patch ensures that both kp->obj and kp->page are not NULL before
calling the respective free functions. In practice, just checking
one or the other should be sufficient since they are assigned together
in zcache_do_preload(), but I check both for safety.
Based on v3.1-rc8
Signed-off-by: Seth Jennings <sjenning@...ux.vnet.ibm.com>
---
drivers/staging/zcache/zcache-main.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c
index 462fbc2..41d1ba1 100644
--- a/drivers/staging/zcache/zcache-main.c
+++ b/drivers/staging/zcache/zcache-main.c
@@ -1357,8 +1357,14 @@ static int zcache_cpu_notifier(struct notifier_block *nb,
kp->objnodes[kp->nr - 1] = NULL;
kp->nr--;
}
- kmem_cache_free(zcache_obj_cache, kp->obj);
- free_page((unsigned long)kp->page);
+ if (kp->obj) {
+ kmem_cache_free(zcache_obj_cache, kp->obj);
+ kp->obj = NULL;
+ }
+ if (kp->page) {
+ free_page((unsigned long)kp->page);
+ kp->page = NULL;
+ }
break;
default:
break;
--
1.7.4.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists