From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752859AbbIZMoi (ORCPT ); Sat, 26 Sep 2015 08:44:38 -0400 Received: from relay1.sgi.com ([192.48.180.66]:59065 "EHLO relay.sgi.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752751AbbIZMoh (ORCPT ); Sat, 26 Sep 2015 08:44:37 -0400 Date: Sat, 26 Sep 2015 07:44:33 -0500 From: Dimitri Sivanich To: Sudip Mukherjee Cc: Greg Kroah-Hartman , Arnd Bergmann , linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] drivers/misc/sgi-gru: fix return of error Message-ID: <20150926124433.GA8669@sgi.com> References: <1442830699-20562-1-git-send-email-sudipm.mukherjee@gmail.com> <1442830699-20562-4-git-send-email-sudipm.mukherjee@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1442830699-20562-4-git-send-email-sudipm.mukherjee@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Acked-by: Dimitri Sivanich On Mon, Sep 21, 2015 at 03:48:19PM +0530, Sudip Mukherjee wrote: > 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 > --- > > The patch at https://patchwork.kernel.org/patch/6394911/ is not applied > and not relevant now as gms is checked before gru_dbg. But the idea for > this patch was obtained from that one. > > drivers/misc/sgi-gru/grutlbpurge.c | 20 ++++++++++---------- > 1 file changed, 10 insertions(+), 10 deletions(-) > > diff --git a/drivers/misc/sgi-gru/grutlbpurge.c b/drivers/misc/sgi-gru/grutlbpurge.c > index 757a8e9..e936d43 100644 > --- a/drivers/misc/sgi-gru/grutlbpurge.c > +++ b/drivers/misc/sgi-gru/grutlbpurge.c > @@ -306,16 +306,16 @@ struct gru_mm_struct *gru_register_mmu_notifier(void) > atomic_inc(&gms->ms_refcnt); > } else { > gms = kzalloc(sizeof(*gms), GFP_KERNEL); > - if (gms) { > - STAT(gms_alloc); > - spin_lock_init(&gms->ms_asid_lock); > - gms->ms_notifier.ops = &gru_mmuops; > - atomic_set(&gms->ms_refcnt, 1); > - init_waitqueue_head(&gms->ms_wait_queue); > - err = __mmu_notifier_register(&gms->ms_notifier, current->mm); > - if (err) > - goto error; > - } > + if (!gms) > + return ERR_PTR(-ENOMEM); > + STAT(gms_alloc); > + spin_lock_init(&gms->ms_asid_lock); > + gms->ms_notifier.ops = &gru_mmuops; > + atomic_set(&gms->ms_refcnt, 1); > + init_waitqueue_head(&gms->ms_wait_queue); > + err = __mmu_notifier_register(&gms->ms_notifier, current->mm); > + if (err) > + goto error; > } > if (gms) > gru_dbg(grudev, "gms %p, refcnt %d\n", gms, > -- > 1.9.1