linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers/firmware/psci: Fix memory leak in alloc_init_cpu_groups()
@ 2020-01-30  3:49 Gavin Shan
  2020-01-30  4:00 ` Gavin Shan
  2020-01-30 11:02 ` Sudeep Holla
  0 siblings, 2 replies; 5+ messages in thread
From: Gavin Shan @ 2020-01-30  3:49 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: mark.rutland, lorenzo.pieralisi

The CPU mask (@tmp) should be free'd on failing to allocating the element
of @cpu_groups[]. Otherwise, it leads to memory leakage because the CPU
mask variable is allocated with CONFIG_CPUMASK_OFFSTACK.

Signed-off-by: Gavin Shan <gshan@redhat.com>
---
 drivers/firmware/psci/psci_checker.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/firmware/psci/psci_checker.c b/drivers/firmware/psci/psci_checker.c
index 6a445397771c..d1d6d1135fed 100644
--- a/drivers/firmware/psci/psci_checker.c
+++ b/drivers/firmware/psci/psci_checker.c
@@ -167,6 +167,7 @@ static int alloc_init_cpu_groups(cpumask_var_t **pcpu_groups)
 			topology_core_cpumask(cpumask_any(tmp));
 
 		if (!alloc_cpumask_var(&cpu_groups[num_groups], GFP_KERNEL)) {
+			free_cpumask_var(tmp);
 			free_cpu_groups(num_groups, &cpu_groups);
 			return -ENOMEM;
 		}
-- 
2.23.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-01-30 21:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-01-30  3:49 [PATCH] drivers/firmware/psci: Fix memory leak in alloc_init_cpu_groups() Gavin Shan
2020-01-30  4:00 ` Gavin Shan
2020-01-30 11:05   ` Sudeep Holla
2020-01-30 21:41     ` Gavin Shan
2020-01-30 11:02 ` Sudeep Holla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).