Patch "clk: imx: scu: Fix memory leak in __imx_clk_gpr_scu()" has been added to the 5.15-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

    clk: imx: scu: Fix memory leak in __imx_clk_gpr_scu()

to the 5.15-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:
     clk-imx-scu-fix-memory-leak-in-__imx_clk_gpr_scu.patch
and it can be found in the queue-5.15 subdirectory.

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



commit 2c066b1479816e90757f202a47ff8fa31ffd041d
Author: Kuan-Wei Chiu <visitorckw@xxxxxxxxx>
Date:   Mon Dec 11 01:19:07 2023 +0800

    clk: imx: scu: Fix memory leak in __imx_clk_gpr_scu()
    
    [ Upstream commit 21c0efbcb45cf94724d17b040ebc03fcd4a81f22 ]
    
    In cases where imx_clk_is_resource_owned() returns false, the code path
    does not handle the failure gracefully, potentially leading to a memory
    leak. This fix ensures proper cleanup by freeing the allocated memory
    for 'clk_node' before returning.
    
    Signed-off-by: Kuan-Wei Chiu <visitorckw@xxxxxxxxx>
    Reviewed-by: Peng Fan <peng.fan@xxxxxxx>
    Link: https://lore.kernel.org/all/20231210171907.3410922-1-visitorckw@xxxxxxxxx/
    Signed-off-by: Abel Vesa <abel.vesa@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/clk/imx/clk-scu.c b/drivers/clk/imx/clk-scu.c
index 1cee88b073fa..89a914a15d62 100644
--- a/drivers/clk/imx/clk-scu.c
+++ b/drivers/clk/imx/clk-scu.c
@@ -841,8 +841,10 @@ struct clk_hw *__imx_clk_gpr_scu(const char *name, const char * const *parent_na
 	if (!clk_node)
 		return ERR_PTR(-ENOMEM);
 
-	if (!imx_scu_clk_is_valid(rsrc_id))
+	if (!imx_scu_clk_is_valid(rsrc_id)) {
+		kfree(clk_node);
 		return ERR_PTR(-EINVAL);
+	}
 
 	clk = kzalloc(sizeof(*clk), GFP_KERNEL);
 	if (!clk) {




[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