From b02d127d0780b2aa79629f10a1fc81ce957d3cbc Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Thu, 31 Dec 2020 22:05:08 +0000 Subject: [PATCH] Make sure nobody's leaking resources Currently, releasing a resource also releases all of its children. That made sense when request_resource was the main method of dividing up the memory map. With the increased use of insert_resource, it seems to me that we should instead reparent the newly orphaned resources. Before we do that, let's make sure that nobody's actually relying on the current semantics. Signed-off-by: Matthew Wilcox Cc: Greg KH Cc: Ivan Kokshaysky Cc: Dominik Brodowski Signed-off-by: Andrew Morton --- kernel/resource.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kernel/resource.c b/kernel/resource.c index 833394f9c608..46c410dccb38 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -214,6 +214,14 @@ static int __release_resource(struct resource *old, bool release_child) { struct resource *tmp, **p, *chd; + if (old->child) { + static int warned; + if (warned < 5) { + warned++; + WARN_ON(1); + } + } + p = &old->parent->child; for (;;) { tmp = *p; -- 2.50.1