mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 12:28:41 +08:00
crypto: ccp - fix memleak in ccp_init_dm_workarea
[ Upstream commita1c95dd5bc
] When dma_map_single() fails, wa->address is supposed to be freed by the callers of ccp_init_dm_workarea() through ccp_dm_free(). However, many of the call spots don't expect to have to call ccp_dm_free() on failure of ccp_init_dm_workarea(), which may lead to a memleak. Let's free wa->address in ccp_init_dm_workarea() when dma_map_single() fails. Fixes:63b945091a
("crypto: ccp - CCP device driver and interface support") Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn> Acked-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
baa79033e1
commit
f3a11fdd02
@ -179,8 +179,11 @@ static int ccp_init_dm_workarea(struct ccp_dm_workarea *wa,
|
||||
|
||||
wa->dma.address = dma_map_single(wa->dev, wa->address, len,
|
||||
dir);
|
||||
if (dma_mapping_error(wa->dev, wa->dma.address))
|
||||
if (dma_mapping_error(wa->dev, wa->dma.address)) {
|
||||
kfree(wa->address);
|
||||
wa->address = NULL;
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
wa->dma.length = len;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user