From: Dimitri Sivanich <sivanich@sgi.com>
To: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Arnd Bergmann <arnd@arndb.de>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] drivers/misc/sgi-gru: fix return of error
Date: Sat, 26 Sep 2015 07:44:33 -0500 [thread overview]
Message-ID: <20150926124433.GA8669@sgi.com> (raw)
In-Reply-To: <1442830699-20562-4-git-send-email-sudipm.mukherjee@gmail.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
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 <sudip@vectorindia.org>
> ---
>
> 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
next prev parent reply other threads:[~2015-09-26 12:44 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-21 10:18 [PATCH 0/3] drivers/misc/sgi-gru: unapplied patches and a new one Sudip Mukherjee
2015-09-21 10:18 ` [PATCH 1/3] sgi-gru: use time_before() Sudip Mukherjee
2015-09-21 10:18 ` [PATCH 2/3] misc: sgi-gru: gruhandles.c: Remove unused function Sudip Mukherjee
2015-09-21 10:18 ` [PATCH 3/3] drivers/misc/sgi-gru: fix return of error Sudip Mukherjee
2015-09-26 12:44 ` Dimitri Sivanich [this message]
2015-09-23 17:48 ` [PATCH 0/3] drivers/misc/sgi-gru: unapplied patches and a new one Dimitri Sivanich
2015-09-24 7:01 ` Sudip Mukherjee
2015-10-05 15:13 ` Sudip Mukherjee
2015-10-05 15:18 ` Dimitri Sivanich
2015-10-14 4:52 ` Sudip Mukherjee
2015-10-14 14:33 ` Dimitri Sivanich
2015-10-26 9:15 ` Sudip Mukherjee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150926124433.GA8669@sgi.com \
--to=sivanich@sgi.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sudipm.mukherjee@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox