All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] mpi/mpi-mpow: NULL dereference on allocation failure
@ 2011-11-21 14:50 ` Dan Carpenter
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2011-11-21 14:50 UTC (permalink / raw)
  To: Dmitry Kasatkin; +Cc: linux-kernel, kernel-janitors

We can't call mpi_free() on the elements if the first kzalloc() fails.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/lib/mpi/mpi-mpow.c b/lib/mpi/mpi-mpow.c
index 4cc7593..7328d0d 100644
--- a/lib/mpi/mpi-mpow.c
+++ b/lib/mpi/mpi-mpow.c
@@ -73,7 +73,7 @@ int mpi_mulpowm(MPI res, MPI *basearray, MPI *exparray, MPI m)
 
 	G = kzalloc((1 << k) * sizeof *G, GFP_KERNEL);
 	if (!G)
-		goto nomem;
+		goto err_out;
 
 	/* and calculate */
 	tmp = mpi_alloc(mpi_get_nlimbs(m) + 1);
@@ -129,5 +129,6 @@ nomem:
 	for (i = 0; i < (1 << k); i++)
 		mpi_free(G[i]);
 	kfree(G);
+err_out:
 	return rc;
 }

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

* [patch] mpi/mpi-mpow: NULL dereference on allocation failure
@ 2011-11-21 14:50 ` Dan Carpenter
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2011-11-21 14:50 UTC (permalink / raw)
  To: Dmitry Kasatkin; +Cc: linux-kernel, kernel-janitors

We can't call mpi_free() on the elements if the first kzalloc() fails.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/lib/mpi/mpi-mpow.c b/lib/mpi/mpi-mpow.c
index 4cc7593..7328d0d 100644
--- a/lib/mpi/mpi-mpow.c
+++ b/lib/mpi/mpi-mpow.c
@@ -73,7 +73,7 @@ int mpi_mulpowm(MPI res, MPI *basearray, MPI *exparray, MPI m)
 
 	G = kzalloc((1 << k) * sizeof *G, GFP_KERNEL);
 	if (!G)
-		goto nomem;
+		goto err_out;
 
 	/* and calculate */
 	tmp = mpi_alloc(mpi_get_nlimbs(m) + 1);
@@ -129,5 +129,6 @@ nomem:
 	for (i = 0; i < (1 << k); i++)
 		mpi_free(G[i]);
 	kfree(G);
+err_out:
 	return rc;
 }

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

* Re: [patch] mpi/mpi-mpow: NULL dereference on allocation failure
  2011-11-21 14:50 ` Dan Carpenter
@ 2011-11-21 15:18   ` Kasatkin, Dmitry
  -1 siblings, 0 replies; 6+ messages in thread
From: Kasatkin, Dmitry @ 2011-11-21 15:18 UTC (permalink / raw)
  To: Dan Carpenter, James Morris; +Cc: linux-kernel, kernel-janitors

On Mon, Nov 21, 2011 at 4:50 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> We can't call mpi_free() on the elements if the first kzalloc() fails.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@intel.com>

>
> diff --git a/lib/mpi/mpi-mpow.c b/lib/mpi/mpi-mpow.c
> index 4cc7593..7328d0d 100644
> --- a/lib/mpi/mpi-mpow.c
> +++ b/lib/mpi/mpi-mpow.c
> @@ -73,7 +73,7 @@ int mpi_mulpowm(MPI res, MPI *basearray, MPI *exparray, MPI m)
>
>        G = kzalloc((1 << k) * sizeof *G, GFP_KERNEL);
>        if (!G)
> -               goto nomem;
> +               goto err_out;
>
>        /* and calculate */
>        tmp = mpi_alloc(mpi_get_nlimbs(m) + 1);
> @@ -129,5 +129,6 @@ nomem:
>        for (i = 0; i < (1 << k); i++)
>                mpi_free(G[i]);
>        kfree(G);
> +err_out:
>        return rc;
>  }
>

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

* Re: [patch] mpi/mpi-mpow: NULL dereference on allocation failure
@ 2011-11-21 15:18   ` Kasatkin, Dmitry
  0 siblings, 0 replies; 6+ messages in thread
From: Kasatkin, Dmitry @ 2011-11-21 15:18 UTC (permalink / raw)
  To: Dan Carpenter, James Morris; +Cc: linux-kernel, kernel-janitors

On Mon, Nov 21, 2011 at 4:50 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> We can't call mpi_free() on the elements if the first kzalloc() fails.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@intel.com>

>
> diff --git a/lib/mpi/mpi-mpow.c b/lib/mpi/mpi-mpow.c
> index 4cc7593..7328d0d 100644
> --- a/lib/mpi/mpi-mpow.c
> +++ b/lib/mpi/mpi-mpow.c
> @@ -73,7 +73,7 @@ int mpi_mulpowm(MPI res, MPI *basearray, MPI *exparray, MPI m)
>
>        G = kzalloc((1 << k) * sizeof *G, GFP_KERNEL);
>        if (!G)
> -               goto nomem;
> +               goto err_out;
>
>        /* and calculate */
>        tmp = mpi_alloc(mpi_get_nlimbs(m) + 1);
> @@ -129,5 +129,6 @@ nomem:
>        for (i = 0; i < (1 << k); i++)
>                mpi_free(G[i]);
>        kfree(G);
> +err_out:
>        return rc;
>  }
>

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

* Re: [patch] mpi/mpi-mpow: NULL dereference on allocation failure
  2011-11-21 14:50 ` Dan Carpenter
@ 2011-11-21 17:00   ` walter harms
  -1 siblings, 0 replies; 6+ messages in thread
From: walter harms @ 2011-11-21 17:00 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Dmitry Kasatkin, linux-kernel, kernel-janitors



Am 21.11.2011 15:50, schrieb Dan Carpenter:
> We can't call mpi_free() on the elements if the first kzalloc() fails.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/lib/mpi/mpi-mpow.c b/lib/mpi/mpi-mpow.c
> index 4cc7593..7328d0d 100644
> --- a/lib/mpi/mpi-mpow.c
> +++ b/lib/mpi/mpi-mpow.c
> @@ -73,7 +73,7 @@ int mpi_mulpowm(MPI res, MPI *basearray, MPI *exparray, MPI m)
>  
>  	G = kzalloc((1 << k) * sizeof *G, GFP_KERNEL);
>  	if (!G)
> -		goto nomem;
> +		goto err_out;
>  
>  	/* and calculate */
>  	tmp = mpi_alloc(mpi_get_nlimbs(m) + 1);
> @@ -129,5 +129,6 @@ nomem:
>  	for (i = 0; i < (1 << k); i++)
>  		mpi_free(G[i]);
>  	kfree(G);
> +err_out:
>  	return rc;
>  }

the patch is ok
but is there any reason *not* to use a more nice name that 'G'
something more descriptive perhaps ?

re,
 wh



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

* Re: [patch] mpi/mpi-mpow: NULL dereference on allocation failure
@ 2011-11-21 17:00   ` walter harms
  0 siblings, 0 replies; 6+ messages in thread
From: walter harms @ 2011-11-21 17:00 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Dmitry Kasatkin, linux-kernel, kernel-janitors



Am 21.11.2011 15:50, schrieb Dan Carpenter:
> We can't call mpi_free() on the elements if the first kzalloc() fails.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/lib/mpi/mpi-mpow.c b/lib/mpi/mpi-mpow.c
> index 4cc7593..7328d0d 100644
> --- a/lib/mpi/mpi-mpow.c
> +++ b/lib/mpi/mpi-mpow.c
> @@ -73,7 +73,7 @@ int mpi_mulpowm(MPI res, MPI *basearray, MPI *exparray, MPI m)
>  
>  	G = kzalloc((1 << k) * sizeof *G, GFP_KERNEL);
>  	if (!G)
> -		goto nomem;
> +		goto err_out;
>  
>  	/* and calculate */
>  	tmp = mpi_alloc(mpi_get_nlimbs(m) + 1);
> @@ -129,5 +129,6 @@ nomem:
>  	for (i = 0; i < (1 << k); i++)
>  		mpi_free(G[i]);
>  	kfree(G);
> +err_out:
>  	return rc;
>  }

the patch is ok
but is there any reason *not* to use a more nice name that 'G'
something more descriptive perhaps ?

re,
 wh



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

end of thread, other threads:[~2011-11-21 17:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-21 14:50 [patch] mpi/mpi-mpow: NULL dereference on allocation failure Dan Carpenter
2011-11-21 14:50 ` Dan Carpenter
2011-11-21 15:18 ` Kasatkin, Dmitry
2011-11-21 15:18   ` Kasatkin, Dmitry
2011-11-21 17:00 ` walter harms
2011-11-21 17:00   ` walter harms

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.