From: Matthew Wilcox Date: Thu, 31 Dec 2020 22:05:08 +0000 (+0000) Subject: Make sure nobody's leaking resources X-Git-Tag: howlett/maple_spf/20210104~75 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=b02d127d0780b2aa79629f10a1fc81ce957d3cbc;p=users%2Fjedix%2Flinux-maple.git 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 --- 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;