All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sgi-gru: fix null pointer dereference on failed kzalloc
@ 2015-05-13  8:19 Colin King
  2015-05-21  1:51 ` Dimitri Sivanich
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2015-05-13  8:19 UTC (permalink / raw
  To: Dimitri Sivanich; +Cc: linux-kernel

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] sgi-gru: fix null pointer dereference on failed kzalloc
  2015-05-13  8:19 [PATCH] sgi-gru: fix null pointer dereference on failed kzalloc Colin King
@ 2015-05-21  1:51 ` Dimitri Sivanich
  0 siblings, 0 replies; 2+ messages in thread
From: Dimitri Sivanich @ 2015-05-21  1:51 UTC (permalink / raw
  To: Colin King; +Cc: linux-kernel

Acked-by: Dimitri Sivanich <sivanich@sgi.com>

On Wed, May 13, 2015 at 09:19:46AM +0100, Colin King wrote:
> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-05-21  2:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-13  8:19 [PATCH] sgi-gru: fix null pointer dereference on failed kzalloc Colin King
2015-05-21  1:51 ` Dimitri Sivanich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.