mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-04 18:19:28 +09:00
crypto: caam - fix hash context DMA unmap size
commit65055e2108upstream. When driver started using state->caam_ctxt for storing both running hash and final hash, it was not updated to handle different DMA unmap lengths. Cc: <stable@vger.kernel.org> # v4.19+ Fixes:c19650d6ea("crypto: caam - fix DMA mapping of stack memory") Signed-off-by: Franck LENORMAND <franck.lenormand@nxp.com> Signed-off-by: Horia Geantă <horia.geanta@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
dd6ce0316e
commit
32eeecf7ac
@@ -118,6 +118,7 @@ struct caam_hash_ctx {
|
||||
struct caam_hash_state {
|
||||
dma_addr_t buf_dma;
|
||||
dma_addr_t ctx_dma;
|
||||
int ctx_dma_len;
|
||||
u8 buf_0[CAAM_MAX_HASH_BLOCK_SIZE] ____cacheline_aligned;
|
||||
int buflen_0;
|
||||
u8 buf_1[CAAM_MAX_HASH_BLOCK_SIZE] ____cacheline_aligned;
|
||||
@@ -170,6 +171,7 @@ static inline int map_seq_out_ptr_ctx(u32 *desc, struct device *jrdev,
|
||||
struct caam_hash_state *state,
|
||||
int ctx_len)
|
||||
{
|
||||
state->ctx_dma_len = ctx_len;
|
||||
state->ctx_dma = dma_map_single(jrdev, state->caam_ctx,
|
||||
ctx_len, DMA_FROM_DEVICE);
|
||||
if (dma_mapping_error(jrdev, state->ctx_dma)) {
|
||||
@@ -223,6 +225,7 @@ static inline int ctx_map_to_sec4_sg(struct device *jrdev,
|
||||
struct caam_hash_state *state, int ctx_len,
|
||||
struct sec4_sg_entry *sec4_sg, u32 flag)
|
||||
{
|
||||
state->ctx_dma_len = ctx_len;
|
||||
state->ctx_dma = dma_map_single(jrdev, state->caam_ctx, ctx_len, flag);
|
||||
if (dma_mapping_error(jrdev, state->ctx_dma)) {
|
||||
dev_err(jrdev, "unable to map ctx\n");
|
||||
@@ -527,12 +530,10 @@ static inline void ahash_unmap_ctx(struct device *dev,
|
||||
struct ahash_edesc *edesc,
|
||||
struct ahash_request *req, int dst_len, u32 flag)
|
||||
{
|
||||
struct crypto_ahash *ahash = crypto_ahash_reqtfm(req);
|
||||
struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash);
|
||||
struct caam_hash_state *state = ahash_request_ctx(req);
|
||||
|
||||
if (state->ctx_dma) {
|
||||
dma_unmap_single(dev, state->ctx_dma, ctx->ctx_len, flag);
|
||||
dma_unmap_single(dev, state->ctx_dma, state->ctx_dma_len, flag);
|
||||
state->ctx_dma = 0;
|
||||
}
|
||||
ahash_unmap(dev, edesc, req, dst_len);
|
||||
@@ -1505,6 +1506,7 @@ static int ahash_init(struct ahash_request *req)
|
||||
state->final = ahash_final_no_ctx;
|
||||
|
||||
state->ctx_dma = 0;
|
||||
state->ctx_dma_len = 0;
|
||||
state->current_buf = 0;
|
||||
state->buf_dma = 0;
|
||||
state->buflen_0 = 0;
|
||||
|
||||
Reference in New Issue
Block a user