提交 74143880 编写于 作者: L Lv Yunlong 提交者: Zheng Zengkai

crypto: qat - Fix a double free in adf_create_ring

stable inclusion
from stable-5.10.37
commit 1faf7e6199b8f3874f1b0e3d046931ecb4925a5a
bugzilla: 51868
CVE: NA

--------------------------------

[ Upstream commit f7cae626 ]

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: a672a9dc ("crypto: qat - Intel(R) QAT transport code")
Signed-off-by: NLv Yunlong <lyl2019@mail.ustc.edu.cn>
Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 787bd95d
...@@ -153,6 +153,7 @@ static int adf_init_ring(struct adf_etr_ring_data *ring) ...@@ -153,6 +153,7 @@ static int adf_init_ring(struct adf_etr_ring_data *ring)
dev_err(&GET_DEV(accel_dev), "Ring address not aligned\n"); dev_err(&GET_DEV(accel_dev), "Ring address not aligned\n");
dma_free_coherent(&GET_DEV(accel_dev), ring_size_bytes, dma_free_coherent(&GET_DEV(accel_dev), ring_size_bytes,
ring->base_addr, ring->dma_addr); ring->base_addr, ring->dma_addr);
ring->base_addr = NULL;
return -EFAULT; return -EFAULT;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册