[PATCH] ARM: mm: fix size rounding-down of arm_add_memory()

Geert Uytterhoeven geert at linux-m68k.org
Thu Nov 27 03:04:47 PST 2014


On Thu, Nov 27, 2014 at 11:50 AM, Ard Biesheuvel
<ard.biesheuvel at linaro.org> wrote:
>>>>> --- a/arch/arm/kernel/setup.c
>>>>> +++ b/arch/arm/kernel/setup.c
>>>>> @@ -641,8 +641,8 @@ int __init arm_add_memory(u64 start, u64 size)
>>>>>        * Ensure that start/size are aligned to a page boundary.
>>>>>        * Size is appropriately rounded down, start is rounded up.
>>>>>        */
>>>>> -     size -= start & ~PAGE_MASK;
>>>>>       aligned_start = PAGE_ALIGN(start);
>>>>> +     size -= aligned_start - start;
>
> Beware that if size if sufficiently small, (i.e., smaller than the
> unaligned leading fraction @ start), this wraps around and produces a
> bogus value.

That could have happened before, couldn't it?

Nevertheless, fixing that can be a follow-up patch?
Unless Yamada-san wants to incorporate the fix in this patch?

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds



More information about the linux-arm-kernel mailing list