Linux cryptographic layer development
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: herbert@gondor.apana.org.au, davem@davemloft.net,
	harsh@chelsio.com, hariprasad@chelsio.com,
	linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 2/2] crypto: chcr - Fix error checking
Date: Thu, 13 Apr 2017 17:04:16 +0300	[thread overview]
Message-ID: <20170413140415.6yikoizav7xaka43@mwanda> (raw)
In-Reply-To: <a0f6ad87c1b9e04304e2ff4b4ddad92e7415f21f.1492085165.git.christophe.jaillet@wanadoo.fr>

On Thu, Apr 13, 2017 at 02:14:30PM +0200, Christophe JAILLET wrote:
> If 'chcr_alloc_shash()' a few lines above fails, 'base_hash' can be an
> error pointer when we 'goto out'.
> So checking for NULL here is not enough because it is likely that
> 'chcr_free_shash' will crash if we pass an error pointer.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Another solution, amybe safer, would be to instrument 'chcr_free_shash' or
> 'crypto_free_shash' to accept an error pointer and return immediatelly in
> such a case.
> ---
>  drivers/crypto/chelsio/chcr_algo.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/crypto/chelsio/chcr_algo.c b/drivers/crypto/chelsio/chcr_algo.c
> index f19590ac8775..41750b97f43c 100644
> --- a/drivers/crypto/chelsio/chcr_algo.c
> +++ b/drivers/crypto/chelsio/chcr_algo.c
> @@ -2351,7 +2351,7 @@ static int chcr_authenc_setkey(struct crypto_aead *authenc, const u8 *key,
>  	}
>  out:
>  	aeadctx->enckey_len = 0;
> -	if (base_hash)
> +	if (!IS_ERR_OR_NULL(base_hash))
>  		chcr_free_shash(base_hash);

Ah...  Ok.  Fine, but redo the first patch anyway because it shouldn't
ever be NULL.

regards,
dan carpenter



  reply	other threads:[~2017-04-13 14:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-13 12:13 [PATCH 0/2] Fix/improve some error handling related to 'chcr_alloc_shash' Christophe JAILLET
2017-04-13 12:14 ` [PATCH 1/2] crypto: chcr - Improve error checking Christophe JAILLET
2017-04-13 14:03   ` Dan Carpenter
2017-04-13 12:14 ` [PATCH 2/2] crypto: chcr - Fix " Christophe JAILLET
2017-04-13 14:04   ` Dan Carpenter [this message]
2017-04-13 14:50     ` Christophe JAILLET
2017-04-13 15:07       ` Harsh Jain
2017-04-13 16:13         ` Dan Carpenter
2017-04-13 16:38           ` Christophe JAILLET

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=20170413140415.6yikoizav7xaka43@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=davem@davemloft.net \
    --cc=hariprasad@chelsio.com \
    --cc=harsh@chelsio.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox