From: Sudip Mukherjee Date: Thu, 10 Sep 2015 10:52:03 +0000 (+0530) Subject: drivers/misc/sgi-gru: fix possible NULL dereference X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=f97ef759999485df485fe19a440d6af02d561140;p=linux-beck.git drivers/misc/sgi-gru: fix possible NULL dereference If mmu_find_ops() returns NULL then we are allocating memory for gms using kzalloc. But kzalloc can return NULL and we were dereferencing gms in gru_dbg(). Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/misc/sgi-gru/grutlbpurge.c b/drivers/misc/sgi-gru/grutlbpurge.c index 2129274ef7ab..757a8e9aabdb 100644 --- a/drivers/misc/sgi-gru/grutlbpurge.c +++ b/drivers/misc/sgi-gru/grutlbpurge.c @@ -317,8 +317,9 @@ struct gru_mm_struct *gru_register_mmu_notifier(void) goto error; } } - gru_dbg(grudev, "gms %p, refcnt %d\n", gms, - atomic_read(&gms->ms_refcnt)); + if (gms) + gru_dbg(grudev, "gms %p, refcnt %d\n", gms, + atomic_read(&gms->ms_refcnt)); return gms; error: kfree(gms);