]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
Protect __release_resource against resources without parents
authorPhil Elwell <phil@raspberrypi.org>
Fri, 13 Mar 2015 12:43:36 +0000 (12:43 +0000)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 15 Aug 2018 17:22:40 +0000 (19:22 +0200)
Without this patch, removing a device tree overlay can crash here.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
kernel/resource.c

index 790f1b807f1285b12557325823ed782d83a84a65..e3320e7c6fd83d2dd03ffb1310e051b6f0aa5d3f 100644 (file)
@@ -246,6 +246,12 @@ static int __release_resource(struct resource *old, bool release_child)
 {
        struct resource *tmp, **p, *chd;
 
+       if (!old->parent) {
+               WARN(old->sibling, "sibling but no parent");
+               if (old->sibling)
+                       return -EINVAL;
+               return 0;
+       }
        p = &old->parent->child;
        for (;;) {
                tmp = *p;