Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Resource: fix wrong resource window calculation

__find_resource() incorrectly returns a resource window which overlaps
an existing allocated window. This happens when the parent's
resource-window spans 0x00000000 to 0xffffffff and is entirely allocated
to all its children resource-windows.

__find_resource() looks for gaps in resource allocation among the
children resource windows. When it encounters the last child window it
blindly tries the range next to one allocated to the last child. Since
the last child's window ends at 0xffffffff the calculation overflows,
leading the algorithm to believe that any window in the range 0x0000000
to 0xfffffff is available for allocation. This leads to a conflicting
window allocation.

Michal Ludvig reported this issue seen on his platform. The following
patch fixes the problem and has been verified by Michal. I believe this
bug has been there for ages. It got exposed by git commit 2bbc6942273b
("PCI : ability to relocate assigned pci-resources")

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
Tested-by: Michal Ludvig <mludvig@logix.net.nz>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Ram Pai and committed by
Linus Torvalds
47ea91b4 92bb062f

+6 -1
+6 -1
kernel/resource.c
··· 419 419 else 420 420 tmp.end = root->end; 421 421 422 + if (tmp.end < tmp.start) 423 + goto next; 424 + 422 425 resource_clip(&tmp, constraint->min, constraint->max); 423 426 arch_remove_reservations(&tmp); 424 427 ··· 439 436 return 0; 440 437 } 441 438 } 442 - if (!this) 439 + 440 + next: if (!this || this->end == root->end) 443 441 break; 442 + 444 443 if (this != old) 445 444 tmp.start = this->end + 1; 446 445 this = this->sibling;