misc: sgi-gru: fix return of error

If kzalloc() fails then gms is NULL and we are returning NULL, but the
functions which called this function gru_register_mmu_notifier() are not
expecting NULL as the return. They are expecting either a valid pointer
or the error code in ERR_PTR.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Sudip Mukherjee 2015-09-21 15:48:19 +05:30 committed by Greg Kroah-Hartman
parent 9dcf9cbfa1
commit a9e5fe5826

View file

@ -306,16 +306,16 @@ struct gru_mm_struct *gru_register_mmu_notifier(void)
atomic_inc(&gms->ms_refcnt); atomic_inc(&gms->ms_refcnt);
} else { } else {
gms = kzalloc(sizeof(*gms), GFP_KERNEL); gms = kzalloc(sizeof(*gms), GFP_KERNEL);
if (gms) { if (!gms)
STAT(gms_alloc); return ERR_PTR(-ENOMEM);
spin_lock_init(&gms->ms_asid_lock); STAT(gms_alloc);
gms->ms_notifier.ops = &gru_mmuops; spin_lock_init(&gms->ms_asid_lock);
atomic_set(&gms->ms_refcnt, 1); gms->ms_notifier.ops = &gru_mmuops;
init_waitqueue_head(&gms->ms_wait_queue); atomic_set(&gms->ms_refcnt, 1);
err = __mmu_notifier_register(&gms->ms_notifier, current->mm); init_waitqueue_head(&gms->ms_wait_queue);
if (err) err = __mmu_notifier_register(&gms->ms_notifier, current->mm);
goto error; if (err)
} goto error;
} }
if (gms) if (gms)
gru_dbg(grudev, "gms %p, refcnt %d\n", gms, gru_dbg(grudev, "gms %p, refcnt %d\n", gms,