linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] lib/mpi: Fixed erroneous check on return value of mpi_resize()
@ 2012-05-05  1:51 Adarsh J
  2012-05-05  3:30 ` Tetsuo Handa
  2012-05-07 13:20 ` Kasatkin, Dmitry
  0 siblings, 2 replies; 4+ messages in thread
From: Adarsh J @ 2012-05-05  1:51 UTC (permalink / raw)
  To: Dmitry Kasatkin, James Morris, Tetsuo Handa, Mimi Zohar, David Howells
  Cc: linux-security-module, linux-kernel, Adarsh J

mpi_resize() returns -ENOMEM on error and 0 on success.

Signed-off-by: Adarsh J <root@hackmaster.in>
---
 lib/mpi/mpicoder.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/mpi/mpicoder.c b/lib/mpi/mpicoder.c
index f26b41f..9949b69 100644
--- a/lib/mpi/mpicoder.c
+++ b/lib/mpi/mpicoder.c
@@ -98,7 +98,7 @@ int mpi_fromstr(MPI val, const char *str)
 	nbytes = (nbits + 7) / 8;
 	nlimbs = (nbytes + BYTES_PER_MPI_LIMB - 1) / BYTES_PER_MPI_LIMB;
 	if (val->alloced < nlimbs)
-		if (!mpi_resize(val, nlimbs))
+		if (mpi_resize(val, nlimbs) < 0)
 			return -ENOMEM;
 	i = BYTES_PER_MPI_LIMB - nbytes % BYTES_PER_MPI_LIMB;
 	i %= BYTES_PER_MPI_LIMB;
-- 
1.7.9.5


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

* Re: [PATCH 1/1] lib/mpi: Fixed erroneous check on return value of mpi_resize()
  2012-05-05  1:51 [PATCH 1/1] lib/mpi: Fixed erroneous check on return value of mpi_resize() Adarsh J
@ 2012-05-05  3:30 ` Tetsuo Handa
  2012-05-07  1:26   ` James Morris
  2012-05-07 13:20 ` Kasatkin, Dmitry
  1 sibling, 1 reply; 4+ messages in thread
From: Tetsuo Handa @ 2012-05-05  3:30 UTC (permalink / raw)
  To: root
  Cc: dmitry.kasatkin, jmorris, zohar, dhowells, linux-security-module,
	linux-kernel

Adarsh J wrote:
> mpi_resize() returns -ENOMEM on error and 0 on success.

Good catch.

But it seems to me that mpi_fromstr() has no in-tree users.
Also, mpi_fromstr() in RHEL 5.8/6.2 has no users.
We forgot to exclude when adding MPI support?

> 
> Signed-off-by: Adarsh J <root@hackmaster.in>
> ---
>  lib/mpi/mpicoder.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/mpi/mpicoder.c b/lib/mpi/mpicoder.c
> index f26b41f..9949b69 100644
> --- a/lib/mpi/mpicoder.c
> +++ b/lib/mpi/mpicoder.c
> @@ -98,7 +98,7 @@ int mpi_fromstr(MPI val, const char *str)
>  	nbytes = (nbits + 7) / 8;
>  	nlimbs = (nbytes + BYTES_PER_MPI_LIMB - 1) / BYTES_PER_MPI_LIMB;
>  	if (val->alloced < nlimbs)
> -		if (!mpi_resize(val, nlimbs))
> +		if (mpi_resize(val, nlimbs) < 0)
>  			return -ENOMEM;
>  	i = BYTES_PER_MPI_LIMB - nbytes % BYTES_PER_MPI_LIMB;
>  	i %= BYTES_PER_MPI_LIMB;
> -- 
> 1.7.9.5

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

* Re: [PATCH 1/1] lib/mpi: Fixed erroneous check on return value of mpi_resize()
  2012-05-05  3:30 ` Tetsuo Handa
@ 2012-05-07  1:26   ` James Morris
  0 siblings, 0 replies; 4+ messages in thread
From: James Morris @ 2012-05-07  1:26 UTC (permalink / raw)
  To: Tetsuo Handa
  Cc: Dmitry Kasatkin, zohar, David Howells, linux-security-module,
	linux-kernel

On Sat, 5 May 2012, Tetsuo Handa wrote:

> Adarsh J wrote:
> > mpi_resize() returns -ENOMEM on error and 0 on success.
> 
> Good catch.
> 
> But it seems to me that mpi_fromstr() has no in-tree users.
> Also, mpi_fromstr() in RHEL 5.8/6.2 has no users.
> We forgot to exclude when adding MPI support?

If that's the case, then it should be removed.

(Removed root@ from cc:)

> 
> > 
> > Signed-off-by: Adarsh J <root@hackmaster.in>
> > ---
> >  lib/mpi/mpicoder.c |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/lib/mpi/mpicoder.c b/lib/mpi/mpicoder.c
> > index f26b41f..9949b69 100644
> > --- a/lib/mpi/mpicoder.c
> > +++ b/lib/mpi/mpicoder.c
> > @@ -98,7 +98,7 @@ int mpi_fromstr(MPI val, const char *str)
> >  	nbytes = (nbits + 7) / 8;
> >  	nlimbs = (nbytes + BYTES_PER_MPI_LIMB - 1) / BYTES_PER_MPI_LIMB;
> >  	if (val->alloced < nlimbs)
> > -		if (!mpi_resize(val, nlimbs))
> > +		if (mpi_resize(val, nlimbs) < 0)
> >  			return -ENOMEM;
> >  	i = BYTES_PER_MPI_LIMB - nbytes % BYTES_PER_MPI_LIMB;
> >  	i %= BYTES_PER_MPI_LIMB;
> > -- 
> > 1.7.9.5
> 

-- 
James Morris
<jmorris@namei.org>

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

* Re: [PATCH 1/1] lib/mpi: Fixed erroneous check on return value of mpi_resize()
  2012-05-05  1:51 [PATCH 1/1] lib/mpi: Fixed erroneous check on return value of mpi_resize() Adarsh J
  2012-05-05  3:30 ` Tetsuo Handa
@ 2012-05-07 13:20 ` Kasatkin, Dmitry
  1 sibling, 0 replies; 4+ messages in thread
From: Kasatkin, Dmitry @ 2012-05-07 13:20 UTC (permalink / raw)
  To: Adarsh J
  Cc: James Morris, Tetsuo Handa, Mimi Zohar, David Howells,
	linux-security-module, linux-kernel

On Sat, May 5, 2012 at 4:51 AM, Adarsh J <root@hackmaster.in> wrote:
> mpi_resize() returns -ENOMEM on error and 0 on success.
>
> Signed-off-by: Adarsh J <root@hackmaster.in>

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

Thanks.

> ---
>  lib/mpi/mpicoder.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/mpi/mpicoder.c b/lib/mpi/mpicoder.c
> index f26b41f..9949b69 100644
> --- a/lib/mpi/mpicoder.c
> +++ b/lib/mpi/mpicoder.c
> @@ -98,7 +98,7 @@ int mpi_fromstr(MPI val, const char *str)
>        nbytes = (nbits + 7) / 8;
>        nlimbs = (nbytes + BYTES_PER_MPI_LIMB - 1) / BYTES_PER_MPI_LIMB;
>        if (val->alloced < nlimbs)
> -               if (!mpi_resize(val, nlimbs))
> +               if (mpi_resize(val, nlimbs) < 0)
>                        return -ENOMEM;
>        i = BYTES_PER_MPI_LIMB - nbytes % BYTES_PER_MPI_LIMB;
>        i %= BYTES_PER_MPI_LIMB;
> --
> 1.7.9.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2012-05-07 13:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-05  1:51 [PATCH 1/1] lib/mpi: Fixed erroneous check on return value of mpi_resize() Adarsh J
2012-05-05  3:30 ` Tetsuo Handa
2012-05-07  1:26   ` James Morris
2012-05-07 13:20 ` Kasatkin, Dmitry

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).