diff mbox

[1/2] crypto: dh - fix dh_max_size

Message ID 1494421469-17125-1-git-send-email-tudor.ambarus@microchip.com (mailing list archive)
State Superseded
Delegated to: Herbert Xu
Headers show

Commit Message

Tudor Ambarus May 10, 2017, 1:04 p.m. UTC
The function should return minimum size for output buffer
or error code if key hasn't been set.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
---
 crypto/dh.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Tudor Ambarus May 12, 2017, 9:41 a.m. UTC | #1
Please ignore this patch set. I will send all the changes in a new
patch set.

On 10.05.2017 16:04, Tudor Ambarus wrote:
> The function should return minimum size for output buffer
> or error code if key hasn't been set.
>
> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
> ---
>  crypto/dh.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/crypto/dh.c b/crypto/dh.c
> index 87e3542..53d17ff 100644
> --- a/crypto/dh.c
> +++ b/crypto/dh.c
> @@ -148,7 +148,7 @@ static int dh_max_size(struct crypto_kpp *tfm)
>  {
>  	struct dh_ctx *ctx = dh_get_ctx(tfm);
>
> -	return mpi_get_size(ctx->p);
> +	return ctx->p ? mpi_get_size(ctx->p) : -EINVAL;
>  }
>
>  static void dh_exit_tfm(struct crypto_kpp *tfm)
>
diff mbox

Patch

diff --git a/crypto/dh.c b/crypto/dh.c
index 87e3542..53d17ff 100644
--- a/crypto/dh.c
+++ b/crypto/dh.c
@@ -148,7 +148,7 @@  static int dh_max_size(struct crypto_kpp *tfm)
 {
 	struct dh_ctx *ctx = dh_get_ctx(tfm);
 
-	return mpi_get_size(ctx->p);
+	return ctx->p ? mpi_get_size(ctx->p) : -EINVAL;
 }
 
 static void dh_exit_tfm(struct crypto_kpp *tfm)