linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Colin King <colin.king@canonical.com>
To: Dimitri Sivanich <sivanich@sgi.com>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] sgi-gru: fix null pointer dereference on failed kzalloc
Date: Wed, 13 May 2015 09:19:46 +0100	[thread overview]
Message-ID: <1431505186-22628-1-git-send-email-colin.king@canonical.com> (raw)

From: Colin Ian King <colin.king@canonical.com>

static analysis from smatch found a potential null dereference:

drivers/misc/sgi-gru/grutlbpurge.c:320 gru_register_mmu_notifier() error:
  potential null dereference 'gms'.  (kzalloc returns null)

bail out with -ENOMEM rather than falling through and printing a debug
message that trips a null dereference.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/misc/sgi-gru/grutlbpurge.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/misc/sgi-gru/grutlbpurge.c b/drivers/misc/sgi-gru/grutlbpurge.c
index 2129274..1239800 100644
--- a/drivers/misc/sgi-gru/grutlbpurge.c
+++ b/drivers/misc/sgi-gru/grutlbpurge.c
@@ -315,6 +315,8 @@ struct gru_mm_struct *gru_register_mmu_notifier(void)
 			err = __mmu_notifier_register(&gms->ms_notifier, current->mm);
 			if (err)
 				goto error;
+		} else {
+			return ERR_PTR(-ENOMEM);
 		}
 	}
 	gru_dbg(grudev, "gms %p, refcnt %d\n", gms,
-- 
2.1.4


             reply	other threads:[~2015-05-13  8:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-13  8:19 Colin King [this message]
2015-05-21  1:51 ` [PATCH] sgi-gru: fix null pointer dereference on failed kzalloc Dimitri Sivanich

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=1431505186-22628-1-git-send-email-colin.king@canonical.com \
    --to=colin.king@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sivanich@sgi.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;
as well as URLs for NNTP newsgroup(s).