Skip to content

Commit

Permalink
crypto: qat - Fix a double free in adf_create_ring
Browse files Browse the repository at this point in the history
In adf_create_ring, if the callee adf_init_ring() failed, the callee will
free the ring->base_addr by dma_free_coherent() and return -EFAULT. Then
adf_create_ring will goto err and the ring->base_addr will be freed again
in adf_cleanup_ring().

My patch sets ring->base_addr to NULL after the first freed to avoid the
double free.

Fixes: a672a9d ("crypto: qat - Intel(R) QAT transport code")
Signed-off-by: Lv Yunlong <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
Yunlongs authored and herbertx committed Apr 9, 2021
1 parent 556b64b commit f7cae62
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/crypto/qat/qat_common/adf_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ static int adf_init_ring(struct adf_etr_ring_data *ring)
dev_err(&GET_DEV(accel_dev), "Ring address not aligned\n");
dma_free_coherent(&GET_DEV(accel_dev), ring_size_bytes,
ring->base_addr, ring->dma_addr);
ring->base_addr = NULL;
return -EFAULT;
}

Expand Down

0 comments on commit f7cae62

Please sign in to comment.