From 2cc65208b6a66254ce0499812ed321ed446fdaa7 Mon Sep 17 00:00:00 2001 From: fengsheng Date: Fri, 31 May 2019 20:09:35 +0800 Subject: [PATCH] sysctl: fix a memory leak. driver inclusion category: feature bugzilla: NA CVE: NA sysctl: fix a memory leak. Signed-off-by: fengsheng Reviewed-by: linsiwei Reviewed-by: Yang Yingliang Signed-off-by: Yang Yingliang --- .../soc/hisilicon/sysctl/sysctl_local_ras.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/soc/hisilicon/sysctl/sysctl_local_ras.c b/drivers/soc/hisilicon/sysctl/sysctl_local_ras.c index b1cbfad96a69..45087fad3af3 100644 --- a/drivers/soc/hisilicon/sysctl/sysctl_local_ras.c +++ b/drivers/soc/hisilicon/sysctl/sysctl_local_ras.c @@ -409,6 +409,7 @@ static int sysctl_ghes_read_estatus(struct ghes *sysctl_ghes, int silent) if (!sysctl_ghes->estatus) { pr_err("[ERROR] SYSCTL RAS sysctl_ghes->estatus is null.\n"); + ret = -ENOENT; goto error_release_estatus; } @@ -517,8 +518,7 @@ static int sysctl_ghes_proc(struct ghes *sysctl_ghes) sysctl_ghes_do_proc(sysctl_ghes, sysctl_ghes->estatus); - if (sysctl_ghes->estatus) - iounmap(sysctl_ghes->estatus); + iounmap(sysctl_ghes->estatus); return ret; } @@ -608,10 +608,23 @@ int hip_sysctl_local_ras_init(void) return ret; } +static void his_ghes_list_free(void) +{ + struct ghes *sysctl_ghes; + + rcu_read_lock(); + list_for_each_entry_rcu(sysctl_ghes, &hisi_ghes_list, list) { + if (sysctl_ghes) + kfree(sysctl_ghes); + } + rcu_read_unlock(); +} + void hip_sysctl_local_ras_exit(void) { - sysctl_lpc_deinit(); + sysctl_lpc_deinit(); + his_ghes_list_free(); unregister_acpi_hed_notifier(&sysctl_ghes_hisi_notifier_hed); pr_info("[INFO] hip sysctl local ras exit.\n"); -- GitLab