All of lore.kernel.org
 help / color / mirror / Atom feed
* re: crypto: nx - add hardware 842 crypto comp alg
@ 2015-05-14 10:09 Dan Carpenter
  2015-05-15  7:04 ` Herbert Xu
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2015-05-14 10:09 UTC (permalink / raw)
  To: ddstreet; +Cc: linux-crypto

Hello Dan Streetman,

This is a semi-automatic email about new static checker warnings.

The patch ed70b479c2c0: "crypto: nx - add hardware 842 crypto comp
alg" from May 7, 2015, leads to the following Smatch complaint:

drivers/crypto/nx/nx-842-crypto.c:301 nx842_crypto_compress()
	 warn: variable dereferenced before check 'tfm' (see line 292)

drivers/crypto/nx/nx-842-crypto.c
   288  static int nx842_crypto_compress(struct crypto_tfm *tfm,
   289                                   const u8 *src, unsigned int slen,
   290                                   u8 *dst, unsigned int *dlen)
   291	{
   292		struct nx842_crypto_ctx *ctx = crypto_tfm_ctx(tfm);
                                                              ^^^
Dereference.

   293		struct nx842_crypto_header *hdr = &ctx->header;
   294		struct nx842_crypto_param p;
   295		struct nx842_constraints c;
   296		unsigned int groups, hdrsize, h;
   297		int ret, n;
   298		bool add_header;
   299		u16 ignore = 0;
   300	
   301		if (!tfm || !src || !slen || !dst || !dlen)
                     ^^^
Checked for NULL.

   302			return -EINVAL;
   303	


The decompress function has the same warning:

	drivers/crypto/nx/nx-842-crypto.c:486 nx842_crypto_decompress()
	warn: variable dereferenced before check 'tfm' (see line 478)

regards,
dan carpenter

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

* Re: re: crypto: nx - add hardware 842 crypto comp alg
  2015-05-14 10:09 crypto: nx - add hardware 842 crypto comp alg Dan Carpenter
@ 2015-05-15  7:04 ` Herbert Xu
  2015-05-15 15:07   ` [PATCH] crypto: remove 842-nx null checks Dan Streetman
  0 siblings, 1 reply; 4+ messages in thread
From: Herbert Xu @ 2015-05-15  7:04 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: ddstreet, linux-crypto

Dan Carpenter <dan.carpenter@oracle.com> wrote:
> Hello Dan Streetman,
> 
> This is a semi-automatic email about new static checker warnings.
> 
> The patch ed70b479c2c0: "crypto: nx - add hardware 842 crypto comp
> alg" from May 7, 2015, leads to the following Smatch complaint:
> 
> drivers/crypto/nx/nx-842-crypto.c:301 nx842_crypto_compress()
>         warn: variable dereferenced before check 'tfm' (see line 292)
> 
> drivers/crypto/nx/nx-842-crypto.c
>   288  static int nx842_crypto_compress(struct crypto_tfm *tfm,
>   289                                   const u8 *src, unsigned int slen,
>   290                                   u8 *dst, unsigned int *dlen)
>   291  {
>   292          struct nx842_crypto_ctx *ctx = crypto_tfm_ctx(tfm);
>                                                              ^^^
> Dereference.
> 
>   293          struct nx842_crypto_header *hdr = &ctx->header;
>   294          struct nx842_crypto_param p;
>   295          struct nx842_constraints c;
>   296          unsigned int groups, hdrsize, h;
>   297          int ret, n;
>   298          bool add_header;
>   299          u16 ignore = 0;
>   300  
>   301          if (!tfm || !src || !slen || !dst || !dlen)
>                     ^^^
> Checked for NULL.
> 
>   302                  return -EINVAL;
>   303  

tfm can never be NULL so this should be removed.

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

* [PATCH] crypto: remove 842-nx null checks
  2015-05-15  7:04 ` Herbert Xu
@ 2015-05-15 15:07   ` Dan Streetman
  2015-05-18  4:25     ` Herbert Xu
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Streetman @ 2015-05-15 15:07 UTC (permalink / raw)
  To: linux-crypto; +Cc: Herbert Xu, Dan Carpenter, Dan Streetman

Remove the null checks for tfm, src, slen, dst, dlen; tfm will never
be null and the other fields are always expected to be set correctly.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Dan Streetman <ddstreet@ieee.org>
---
 drivers/crypto/nx/nx-842-crypto.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/crypto/nx/nx-842-crypto.c b/drivers/crypto/nx/nx-842-crypto.c
index cb177c3..2ffa103 100644
--- a/drivers/crypto/nx/nx-842-crypto.c
+++ b/drivers/crypto/nx/nx-842-crypto.c
@@ -298,9 +298,6 @@ static int nx842_crypto_compress(struct crypto_tfm *tfm,
 	bool add_header;
 	u16 ignore = 0;
 
-	if (!tfm || !src || !slen || !dst || !dlen)
-		return -EINVAL;
-
 	p.in = (u8 *)src;
 	p.iremain = slen;
 	p.out = dst;
@@ -483,9 +480,6 @@ static int nx842_crypto_decompress(struct crypto_tfm *tfm,
 	u16 ignore = 0;
 	bool usehw = true;
 
-	if (!tfm || !src || !slen || !dst || !dlen)
-		return -EINVAL;
-
 	p.in = (u8 *)src;
 	p.iremain = slen;
 	p.out = dst;
-- 
2.1.0

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

* Re: [PATCH] crypto: remove 842-nx null checks
  2015-05-15 15:07   ` [PATCH] crypto: remove 842-nx null checks Dan Streetman
@ 2015-05-18  4:25     ` Herbert Xu
  0 siblings, 0 replies; 4+ messages in thread
From: Herbert Xu @ 2015-05-18  4:25 UTC (permalink / raw)
  To: Dan Streetman; +Cc: linux-crypto, Dan Carpenter

On Fri, May 15, 2015 at 11:07:33AM -0400, Dan Streetman wrote:
> Remove the null checks for tfm, src, slen, dst, dlen; tfm will never
> be null and the other fields are always expected to be set correctly.
> 
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Dan Streetman <ddstreet@ieee.org>

Applied.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

end of thread, other threads:[~2015-05-18  4:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-14 10:09 crypto: nx - add hardware 842 crypto comp alg Dan Carpenter
2015-05-15  7:04 ` Herbert Xu
2015-05-15 15:07   ` [PATCH] crypto: remove 842-nx null checks Dan Streetman
2015-05-18  4:25     ` Herbert Xu

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.