Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 219563
b: refs/heads/master
c: a1862e3
h: refs/heads/master
i:
  219561: f2bb4d1
  219559: c95e37b
v: v3
  • Loading branch information
Bjorn Helgaas authored and Jesse Barnes committed Oct 26, 2010
1 parent 577d2c6 commit 24ac706
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6909ba14c25b4db6be2ff89f4fa0fac2d70151a0
refs/heads/master: a1862e31079149a52b6223776228c3aee493d4a7
21 changes: 13 additions & 8 deletions trunk/kernel/resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ static int find_resource(struct resource *root, struct resource *new,
void *alignf_data)
{
struct resource *this = root->child;
struct resource tmp = *new, alloc;
struct resource tmp = *new, avail, alloc;

tmp.start = root->start;
/*
Expand All @@ -410,14 +410,19 @@ static int find_resource(struct resource *root, struct resource *new,
tmp.end = root->end;

resource_clip(&tmp, min, max);
tmp.start = ALIGN(tmp.start, align);

alloc.start = alignf(alignf_data, &tmp, size, align);
alloc.end = alloc.start + size - 1;
if (resource_contains(&tmp, &alloc)) {
new->start = alloc.start;
new->end = alloc.end;
return 0;
/* Check for overflow after ALIGN() */
avail = *new;
avail.start = ALIGN(tmp.start, align);
avail.end = tmp.end;
if (avail.start >= tmp.start) {
alloc.start = alignf(alignf_data, &avail, size, align);
alloc.end = alloc.start + size - 1;
if (resource_contains(&avail, &alloc)) {
new->start = alloc.start;
new->end = alloc.end;
return 0;
}
}
if (!this)
break;
Expand Down

0 comments on commit 24ac706

Please sign in to comment.