From: Li Wei Date: Mon, 28 Jul 2014 03:57:14 +0000 (+0800) Subject: LU-5422 obdclass: Fix null pointer derefs in lu_cache_shrink() X-Git-Tag: 2.6.51~35 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=d6ab7f7304cc8e0dbc971a098a6f4d0a8ad96dcf LU-5422 obdclass: Fix null pointer derefs in lu_cache_shrink() When lu_cache_shrink() is called on a machine with no Lustre targets mounted, the following null pointer dereference may happen: BUG: unable to handle kernel NULL pointer dereference at (null) IP: [] lu_cache_shrink+0x156/0x310 [obdclass] This is a regression introduced recently by 8701e7e. lu_sites must be initialized before the lu_sites shrinker is registered. And, it cannot be re-initialized every time when an lu_site is initialized. Change-Id: Ieebd2ff1bcde4096037658a22956355283122182 Signed-off-by: Li Wei Reviewed-on: http://review.whamcloud.com/11244 Tested-by: Jenkins Reviewed-by: James Simmons Tested-by: Maloo Reviewed-by: Emoly Liu Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin --- diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c index cc43d7c..d880ba4 100644 --- a/lustre/obdclass/lu_object.c +++ b/lustre/obdclass/lu_object.c @@ -1098,8 +1098,6 @@ int lu_site_init(struct lu_site *s, struct lu_device *top) int i; ENTRY; - INIT_LIST_HEAD(&lu_sites); - memset(s, 0, sizeof *s); mutex_init(&s->ls_purge_mutex); bits = lu_htable_order(top); @@ -2112,6 +2110,7 @@ int lu_global_init(void) INIT_LIST_HEAD(&lu_device_types); INIT_LIST_HEAD(&lu_context_remembered); + INIT_LIST_HEAD(&lu_sites); result = lu_ref_global_init(); if (result != 0)