Skip to content

Commit

Permalink
drivers/misc/sgi-gru: fix possible NULL dereference
Browse files Browse the repository at this point in the history
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 <sudip@vectorindia.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Sudip Mukherjee authored and Greg Kroah-Hartman committed Sep 21, 2015
1 parent 6894fda commit f97ef75
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/misc/sgi-gru/grutlbpurge.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f97ef75

Please sign in to comment.