Skip to content

Commit eb7713f

Browse files
haresh-intelherbertx
authored andcommitted
crypto: qat - unmap buffer before free for DH
The callback function for DH frees the memory allocated for the destination buffer before unmapping it. This sequence is wrong. Change the cleanup sequence to unmap the buffer before freeing it. Fixes: 029aa46 ("crypto: qat - remove dma_free_coherent() for DH") Signed-off-by: Hareshx Sankar Raj <[email protected]> Co-developed-by: Bolemx Sivanagaleela <[email protected]> Signed-off-by: Bolemx Sivanagaleela <[email protected]> Reviewed-by: Giovanni Cabiddu <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Giovanni Cabiddu <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent e302309 commit eb7713f

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/crypto/intel/qat/qat_common/qat_asym_algs.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,14 @@ static void qat_dh_cb(struct icp_qat_fw_pke_resp *resp)
170170
}
171171

172172
areq->dst_len = req->ctx.dh->p_size;
173+
dma_unmap_single(dev, req->out.dh.r, req->ctx.dh->p_size,
174+
DMA_FROM_DEVICE);
173175
if (req->dst_align) {
174176
scatterwalk_map_and_copy(req->dst_align, areq->dst, 0,
175177
areq->dst_len, 1);
176178
kfree_sensitive(req->dst_align);
177179
}
178180

179-
dma_unmap_single(dev, req->out.dh.r, req->ctx.dh->p_size,
180-
DMA_FROM_DEVICE);
181-
182181
dma_unmap_single(dev, req->phy_in, sizeof(struct qat_dh_input_params),
183182
DMA_TO_DEVICE);
184183
dma_unmap_single(dev, req->phy_out,

0 commit comments

Comments
 (0)