diff mbox series

clk: socfpga: arria10: Fix memory leak of socfpga_clk on error return

Message ID 20210406170115.430990-1-colin.king@canonical.com (mailing list archive)
State Accepted, archived
Headers show
Series clk: socfpga: arria10: Fix memory leak of socfpga_clk on error return | expand

Commit Message

Colin King April 6, 2021, 5:01 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

There is an error return path that is not kfree'ing socfpga_clk leading
to a memory leak. Fix this by adding in the missing kfree call.

Addresses-Coverity: ("Resource leak")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/clk/socfpga/clk-gate-a10.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Dinh Nguyen April 6, 2021, 6:13 p.m. UTC | #1
On 4/6/21 12:01 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> There is an error return path that is not kfree'ing socfpga_clk leading
> to a memory leak. Fix this by adding in the missing kfree call.
> 
> Addresses-Coverity: ("Resource leak")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   drivers/clk/socfpga/clk-gate-a10.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/clk/socfpga/clk-gate-a10.c b/drivers/clk/socfpga/clk-gate-a10.c
> index f5cba8298712..738c53391e39 100644
> --- a/drivers/clk/socfpga/clk-gate-a10.c
> +++ b/drivers/clk/socfpga/clk-gate-a10.c
> @@ -146,6 +146,7 @@ static void __init __socfpga_gate_init(struct device_node *node,
>   		if (IS_ERR(socfpga_clk->sys_mgr_base_addr)) {
>   			pr_err("%s: failed to find altr,sys-mgr regmap!\n",
>   					__func__);
> +			kfree(socfpga_clk);
>   			return;
>   		}
>   	}
> 

Acked-by: Dinh Nguyen <dinguyen@kernel.org>
Krzysztof Kozlowski April 7, 2021, 8:59 a.m. UTC | #2
On 06/04/2021 19:01, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> There is an error return path that is not kfree'ing socfpga_clk leading
> to a memory leak. Fix this by adding in the missing kfree call.
> 
> Addresses-Coverity: ("Resource leak")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/clk/socfpga/clk-gate-a10.c | 1 +
>  1 file changed, 1 insertion(+)


Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>


Best regards,
Krzysztof
Stephen Boyd April 7, 2021, 11:29 p.m. UTC | #3
Quoting Colin King (2021-04-06 10:01:15)
> From: Colin Ian King <colin.king@canonical.com>
> 
> There is an error return path that is not kfree'ing socfpga_clk leading
> to a memory leak. Fix this by adding in the missing kfree call.
> 
> Addresses-Coverity: ("Resource leak")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---

Applied to clk-next
diff mbox series

Patch

diff --git a/drivers/clk/socfpga/clk-gate-a10.c b/drivers/clk/socfpga/clk-gate-a10.c
index f5cba8298712..738c53391e39 100644
--- a/drivers/clk/socfpga/clk-gate-a10.c
+++ b/drivers/clk/socfpga/clk-gate-a10.c
@@ -146,6 +146,7 @@  static void __init __socfpga_gate_init(struct device_node *node,
 		if (IS_ERR(socfpga_clk->sys_mgr_base_addr)) {
 			pr_err("%s: failed to find altr,sys-mgr regmap!\n",
 					__func__);
+			kfree(socfpga_clk);
 			return;
 		}
 	}