]> git.baikalelectronics.ru Git - kernel.git/commit
of: check for size < 0 after rounding in early_init_dt_add_memory_arch
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Wed, 29 Oct 2014 16:09:32 +0000 (17:09 +0100)
committerGrant Likely <grant.likely@linaro.org>
Tue, 4 Nov 2014 16:43:10 +0000 (16:43 +0000)
commit6061d8e9c9c9e1d120ba5ab73f12fdc91e5b2b6b
tree76ea435917e5cfd97859a813103a3aaa52ae5124
parent3ba7cd41663ba596e2b4d075be5cd984e3092d0f
of: check for size < 0 after rounding in early_init_dt_add_memory_arch

Memory regions passed to early_init_dt_add_memory_arch() are rounded to
PAGE_SIZE by subtracting the size of the leading fractional page from
the 'size' argument. However, size being a u64 type, if its value is
sufficiently small, the subtraction wraps around and produces a bogus
value, potentially leading to crashes.

Fix this by ignoring the memory range in such cases.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Grant Likely <grant.likely@linaro.org>
drivers/of/fdt.c