]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
Make sure nobody's leaking resources
authorMatthew Wilcox <matthew@wil.cx>
Thu, 31 Dec 2020 22:05:08 +0000 (22:05 +0000)
committerJohannes Weiner <hannes@cmpxchg.org>
Thu, 31 Dec 2020 22:05:08 +0000 (22:05 +0000)
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 <matthew@wil.cx>
Cc: Greg KH <greg@kroah.com>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
kernel/resource.c

index 833394f9c608573877af5407a7f13ff7f9e6773b..46c410dccb38a4200fd5fda1a65795079cf7e3a6 100644 (file)
@@ -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;