Patch "crypto: ccp - fix memleak in ccp_init_dm_workarea" has been added to the 6.7-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    crypto: ccp - fix memleak in ccp_init_dm_workarea

to the 6.7-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     crypto-ccp-fix-memleak-in-ccp_init_dm_workarea.patch
and it can be found in the queue-6.7 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 4a52d8e3d0c8668dea7e0902d2df870a58039a0f
Author: Dinghao Liu <dinghao.liu@xxxxxxxxxx>
Date:   Mon Nov 27 11:47:10 2023 +0800

    crypto: ccp - fix memleak in ccp_init_dm_workarea
    
    [ Upstream commit a1c95dd5bc1d6a5d7a75a376c2107421b7d6240d ]
    
    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: 63b945091a07 ("crypto: ccp - CCP device driver and interface support")
    Signed-off-by: Dinghao Liu <dinghao.liu@xxxxxxxxxx>
    Acked-by: Tom Lendacky <thomas.lendacky@xxxxxxx>
    Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/crypto/ccp/ccp-ops.c b/drivers/crypto/ccp/ccp-ops.c
index aa4e1a500691..cb8e99936abb 100644
--- a/drivers/crypto/ccp/ccp-ops.c
+++ b/drivers/crypto/ccp/ccp-ops.c
@@ -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;
 	}




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux