On Tue, Dec 10, 2024 at 09:48:33PM +0100, Christian Marangi wrote: > > +static int eip93_hash_export(struct ahash_request *req, void *out) > +{ > + struct eip93_hash_reqctx *rctx = ahash_request_ctx(req); > + struct eip93_hash_export_state *state = out; > + > + /* Save the first block in state data */ > + if (rctx->len) { > + struct mkt_hash_block *block; > + > + block = list_first_entry(&rctx->blocks, > + struct mkt_hash_block, > + list); > + > + memcpy(state->data, block->data, > + SHA256_BLOCK_SIZE - rctx->left_last); > + } > + > + eip93_hash_export_sa_state(req, state); > + > + eip93_hash_free_data_blocks(req); > + eip93_hash_free_sa_state(req); > + eip93_hash_free_sa_record(req); The export function should be idempotent so it shouldn't be freeing anything. In fact this indicates a bigger problem with how DMA is being used in the driver. You shouldn't be leaving DMA memory mapped after the init (or update) function completes. It is perfectly legal for a user to call init and then abandon the request by freeing it directly without ever calling final. In that case you will be leaking the DMA mappings. So make sure that DMA is mapped only when needed, and freed before you call the user callback. The import/export functions should only be touching kernel memory, not DMA. Cheers, -- Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt