Linux cryptographic layer development
 help / color / mirror / Atom feed
* [PATCH] crypto: ccp - fix memleak in ccp_init_dm_workarea
@ 2023-11-23  7:03 Dinghao Liu
  2023-11-25 15:10 ` Tom Lendacky
  0 siblings, 1 reply; 3+ messages in thread
From: Dinghao Liu @ 2023-11-23  7:03 UTC (permalink / raw)
  To: dinghao.liu
  Cc: Tom Lendacky, John Allen, Herbert Xu, David S. Miller,
	linux-crypto, linux-kernel

When dma_map_single() fails, we should free wa->address to
prevent potential memleak.

Fixes: 63b945091a07 ("crypto: ccp - CCP device driver and interface support")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
 drivers/crypto/ccp/ccp-ops.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/ccp/ccp-ops.c b/drivers/crypto/ccp/ccp-ops.c
index aa4e1a500691..45552ae6347e 100644
--- a/drivers/crypto/ccp/ccp-ops.c
+++ b/drivers/crypto/ccp/ccp-ops.c
@@ -179,8 +179,10 @@ 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);
 			return -ENOMEM;
+		}
 
 		wa->dma.length = len;
 	}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-11-27  2:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-23  7:03 [PATCH] crypto: ccp - fix memleak in ccp_init_dm_workarea Dinghao Liu
2023-11-25 15:10 ` Tom Lendacky
2023-11-27  1:45   ` dinghao.liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox