Patch "RDMA/hfi1: fix potential memory leak in setup_base_ctxt()" has been added to the 5.4-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

    RDMA/hfi1: fix potential memory leak in setup_base_ctxt()

to the 5.4-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:
     rdma-hfi1-fix-potential-memory-leak-in-setup_base_ct.patch
and it can be found in the queue-5.4 subdirectory.

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



commit ca7cc7ef66c92eaf5fc4311d7d8be0110ea29c20
Author: Jianglei Nie <niejianglei2021@xxxxxxx>
Date:   Mon Jul 11 15:07:18 2022 +0800

    RDMA/hfi1: fix potential memory leak in setup_base_ctxt()
    
    [ Upstream commit aa2a1df3a2c85f855af7d54466ac10bd48645d63 ]
    
    setup_base_ctxt() allocates a memory chunk for uctxt->groups with
    hfi1_alloc_ctxt_rcv_groups(). When init_user_ctxt() fails, uctxt->groups
    is not released, which will lead to a memory leak.
    
    We should release the uctxt->groups with hfi1_free_ctxt_rcv_groups()
    when init_user_ctxt() fails.
    
    Fixes: e87473bc1b6c ("IB/hfi1: Only set fd pointer when base context is completely initialized")
    Link: https://lore.kernel.org/r/20220711070718.2318320-1-niejianglei2021@xxxxxxx
    Signed-off-by: Jianglei Nie <niejianglei2021@xxxxxxx>
    Acked-by: Dennis Dalessandro <dennis.dalessandro@xxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Leon Romanovsky <leon@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/infiniband/hw/hfi1/file_ops.c b/drivers/infiniband/hw/hfi1/file_ops.c
index 8c7ba7bad42b..efd977f70f9e 100644
--- a/drivers/infiniband/hw/hfi1/file_ops.c
+++ b/drivers/infiniband/hw/hfi1/file_ops.c
@@ -1224,8 +1224,10 @@ static int setup_base_ctxt(struct hfi1_filedata *fd,
 		goto done;
 
 	ret = init_user_ctxt(fd, uctxt);
-	if (ret)
+	if (ret) {
+		hfi1_free_ctxt_rcv_groups(uctxt);
 		goto done;
+	}
 
 	user_init(uctxt);
 



[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