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

Masahiro Yamada yamada.m at jp.panasonic.com
Fri Nov 28 04:34:45 PST 2014


Hi.


On Thu, 27 Nov 2014 12:04:47 +0100
Geert Uytterhoeven <geert at linux-m68k.org> wrote:

> 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.

Uh-oh, yes. I missed this.


> 
> 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?

We don't two patches to fix one place.

If you are willing to fix it,
please feel free to discard mine and send a new patch.


(If nobody would fix that, I am happy to contribute
for fixing this issue, of course.)



Best Regards
Masahiro Yamada




More information about the linux-arm-kernel mailing list