Devicetree bugfixe for v3.16

Important bug fix for parsing 64-bit addresses on 32-bit platforms.
 Without this patch the kernel will try to use memory ranges that cannot
 be reached.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJTuRSlAAoJEMWQL496c2LNyeAP/3xVkBxtXzaLDU39ijCr5x6B
 2PoagkCapWSCp2GXv29wJii3YgO6cVa54T1p6lbDNLkmzLzBrywq8zcLCOgaAh9G
 3QAulbSAW2nBNMf+8tJ/a86PhOLd6414myrtlvS6LdgRhZQKqzXpHQcEAhkJKIQZ
 YNjE6aW5KtKpiRFToXh166AriL0KYHIbyT0AW3ut5gNUSC+I5X7kLMvw4CsfqexQ
 Mf1P5QkK9Bfk6ss9dTwNYLlenjnKiOVEh7wq6MkcK7JDIP5mSfr5+NgGZpqYsKwR
 eF2lJ8zTmQC+Qjfz20b4ZBu935KmjDklQ7q5FQR3kE3kbCVB9lxYijpvb/51x1h9
 ZpU7fG8gv0KneuJazL2SbqIUEN80DgFZMAy34ohyR+PcFcRkv1rHgbGSq840LjDe
 jBs5xVaDqm5eAwYfPS+DYwB/0SFGEeyx4A9EpEpil5/esVeRwsS6HDkmNGfms5OQ
 SRTyDdxFWhdBphbrcBBT93kc06lnXmISNaMj2njmRtiUDOQEFfVol6MXgjligNPE
 yOTODWZmPmnjXH15DmXxWUKyLGgYqruVQthFo9F94eqT4BXJiPICnJ4xt4oRmGGf
 4VexG2NN0dN7TymvLKp0TUIPSYDGCGZpYA0K+82PfHnRd1PinX2iTL1wO02hLn8A
 uNphY1FdjFbwSPJOqj92
 =7+H1
 -----END PGP SIGNATURE-----

Merge tag 'dt-for-linus' of git://git.secretlab.ca/git/linux

Pull devicetree bugfix from Grant Likely:
 "Important bug fix for parsing 64-bit addresses on 32-bit platforms.
  Without this patch the kernel will try to use memory ranges that
  cannot be reached"

* tag 'dt-for-linus' of git://git.secretlab.ca/git/linux:
  of: Check for phys_addr_t overflows in early_init_dt_add_memory_arch
This commit is contained in:
Linus Torvalds 2014-07-06 12:11:57 -07:00
commit 100193f5b7
1 changed files with 15 additions and 0 deletions

View File

@ -880,6 +880,21 @@ void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size)
const u64 phys_offset = __pa(PAGE_OFFSET);
base &= PAGE_MASK;
size &= PAGE_MASK;
if (sizeof(phys_addr_t) < sizeof(u64)) {
if (base > ULONG_MAX) {
pr_warning("Ignoring memory block 0x%llx - 0x%llx\n",
base, base + size);
return;
}
if (base + size > ULONG_MAX) {
pr_warning("Ignoring memory range 0x%lx - 0x%llx\n",
ULONG_MAX, base + size);
size = ULONG_MAX - base;
}
}
if (base + size < phys_offset) {
pr_warning("Ignoring memory block 0x%llx - 0x%llx\n",
base, base + size);