All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roel Kluin <roel.kluin@gmail.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Neil Horman <nhorman@tuxdriver.com>,
	"David S. Miller" <davem@davemloft.net>,
	linux-crypto@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] crypto: Fix test in get_prng_bytes()
Date: Mon, 12 Oct 2009 16:22:05 +0200	[thread overview]
Message-ID: <4AD33B8D.4030708@gmail.com> (raw)
In-Reply-To: <20091012140753.GA30300@gondor.apana.org.au>

Op 12-10-09 16:07, Herbert Xu schreef:
> On Mon, Oct 12, 2009 at 09:51:42AM -0400, Neil Horman wrote:
> .
>>> Or should this test be removed?
>>>
>>> diff --git a/crypto/ansi_cprng.c b/crypto/ansi_cprng.c
>>> index 3aa6e38..9162456 100644
>>> --- a/crypto/ansi_cprng.c
>>> +++ b/crypto/ansi_cprng.c
>>> @@ -192,7 +192,7 @@ static int get_prng_bytes(char *buf, size_t nbytes, struct prng_context *ctx)
>>>  	int err;
>>>  
>>>  
>>> -	if (nbytes < 0)
>>> +	if ((ssize_t)nbytes < 0)
>>>  		return -EINVAL;
>>>  
>>>  	spin_lock_bh(&ctx->prng_lock);
>> No, you're quite right, its a harmless, but unneeded check.  Herbert, could you
>> pull this into cryptodev please?  Thank you.
> 
> Hmm, if it's unneeded why don't we just kill it instead?

In that case:
-------------------------->8------------------8<-------------------------
size_t nbytes cannot be less than 0 and the test was redundant.

Acked-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
diff --git a/crypto/ansi_cprng.c b/crypto/ansi_cprng.c
index 3aa6e38..47995ae 100644
--- a/crypto/ansi_cprng.c
+++ b/crypto/ansi_cprng.c
@@ -192,9 +192,6 @@ static int get_prng_bytes(char *buf, size_t nbytes, struct prng_context *ctx)
 	int err;
 
 
-	if (nbytes < 0)
-		return -EINVAL;

  reply	other threads:[~2009-10-12 14:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-12 13:09 [PATCH] crypto: Fix test in get_prng_bytes() Roel Kluin
2009-10-12 13:51 ` Neil Horman
2009-10-12 14:07   ` Herbert Xu
2009-10-12 14:22     ` Roel Kluin [this message]
2009-10-12 14:29       ` Neil Horman
2009-10-27 10:52         ` Herbert Xu
2009-10-12 14:28     ` Neil Horman

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=4AD33B8D.4030708@gmail.com \
    --to=roel.kluin@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=nhorman@tuxdriver.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 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.