]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
drivers/misc/sgi-gru: fix possible NULL dereference
authorSudip Mukherjee <sudipm.mukherjee@gmail.com>
Thu, 10 Sep 2015 10:52:03 +0000 (16:22 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 21 Sep 2015 02:33:29 +0000 (19:33 -0700)
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>
drivers/misc/sgi-gru/grutlbpurge.c

index 2129274ef7ab0b833fe491c251ef67822833a703..757a8e9aabdba90348b1dc6c666929868ec4723f 100644 (file)
@@ -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);