Skip to content

Commit 82ec90e

Browse files
Yinghai Lubjorn-helgaas
authored andcommitted
resources: allow adjust_resource() for resources with no parent
If a resource has no parent, allow its start/end to be set arbitrarily as long as any children are still contained within the new range. [bhelgaas: changelog] Signed-off-by: Yinghai Lu <yinghai@kernel.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
1 parent 5cc62c2 commit 82ec90e

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

‎kernel/resource.c‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -722,14 +722,12 @@ int adjust_resource(struct resource *res, resource_size_t start, resource_size_t
722722

723723
write_lock(&resource_lock);
724724

725+
if (!parent)
726+
goto skip;
727+
725728
if ((start < parent->start) || (end > parent->end))
726729
goto out;
727730

728-
for (tmp = res->child; tmp; tmp = tmp->sibling) {
729-
if ((tmp->start < start) || (tmp->end > end))
730-
goto out;
731-
}
732-
733731
if (res->sibling && (res->sibling->start <= end))
734732
goto out;
735733

@@ -741,6 +739,11 @@ int adjust_resource(struct resource *res, resource_size_t start, resource_size_t
741739
goto out;
742740
}
743741

742+
skip:
743+
for (tmp = res->child; tmp; tmp = tmp->sibling)
744+
if ((tmp->start < start) || (tmp->end > end))
745+
goto out;
746+
744747
res->start = start;
745748
res->end = end;
746749
result = 0;

0 commit comments

Comments
 (0)