Skip to content

Commit

Permalink
crypto: ccree - fix mem leak on error path
Browse files Browse the repository at this point in the history
commit d574b70 upstream.

Fix a memory leak on the error path of IV generation code.

Signed-off-by: Gilad Ben-Yossef <[email protected]>
Cc: [email protected] # v4.19+
Signed-off-by: Herbert Xu <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
gby authored and gregkh committed May 22, 2019
1 parent 23a072d commit 2e1679f
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions drivers/crypto/ccree/cc_ivgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,6 @@ void cc_ivgen_fini(struct cc_drvdata *drvdata)
}

ivgen_ctx->pool = NULL_SRAM_ADDR;

/* release "this" context */
kfree(ivgen_ctx);
}

/*!
Expand All @@ -174,10 +171,12 @@ int cc_ivgen_init(struct cc_drvdata *drvdata)
int rc;

/* Allocate "this" context */
ivgen_ctx = kzalloc(sizeof(*ivgen_ctx), GFP_KERNEL);
ivgen_ctx = devm_kzalloc(device, sizeof(*ivgen_ctx), GFP_KERNEL);
if (!ivgen_ctx)
return -ENOMEM;

drvdata->ivgen_handle = ivgen_ctx;

/* Allocate pool's header for initial enc. key/IV */
ivgen_ctx->pool_meta = dma_alloc_coherent(device, CC_IVPOOL_META_SIZE,
&ivgen_ctx->pool_meta_dma,
Expand All @@ -196,8 +195,6 @@ int cc_ivgen_init(struct cc_drvdata *drvdata)
goto out;
}

drvdata->ivgen_handle = ivgen_ctx;

return cc_init_iv_sram(drvdata);

out:
Expand Down

0 comments on commit 2e1679f

Please sign in to comment.