diff --git a/kernel/resource.c b/kernel/resource.c index 0004b8b36479..6681ee6008e5 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -502,7 +502,8 @@ static int __find_resource(struct resource *root, struct resource *old, alloc.start = constraint->alignf(constraint->alignf_data, &avail, size, constraint->align); alloc.end = alloc.start + size - 1; - if (resource_contains(&avail, &alloc)) { + if (alloc.start <= alloc.end && + resource_contains(&avail, &alloc)) { new->start = alloc.start; new->end = alloc.end; return 0;