[U-Boot] [PATCH v10 03/10] lib: lmb: reserving overlapping regions should fail

Simon Glass sjg at chromium.org
Wed Jan 16 21:34:24 UTC 2019


On Mon, 14 Jan 2019 at 14:38, Simon Goldschmidt
<simon.k.r.goldschmidt at gmail.com> wrote:
>
> lmb_add_region handles overlapping regions wrong: instead of merging
> or rejecting to add a new reserved region that overlaps an existing
> one, it just adds the new region.
>
> Since internally the same function is used for lmb_alloc, change
> lmb_add_region to reject overlapping regions.
>
> Also, to keep reserved memory correct after 'free', reserved entries
> created by allocating memory must not set their size to a multiple
> of alignment but to the original size. This ensures the reserved
> region is completely removed when the caller calls 'lmb_free', as
> this one takes the same size as passed to 'lmb_alloc' etc.
>
> Add test to assert this.
>
> Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt at gmail.com>
> ---
>
> Changes in v10: None
> Changes in v9: None
> Changes in v8: None
> Changes in v7:
> - add braces around if/else with macros accross more than one line
>
> Changes in v6:
> - fix size of allocated regions that need alignment padding
>
> Changes in v5:
> - added a test for this bug
>
> Changes in v4: None
> Changes in v2: None
>
>  lib/lmb.c      | 11 +++---
>  test/lib/lmb.c | 95 +++++++++++++++++++++++++++++++++++++++++++++-----
>  2 files changed, 91 insertions(+), 15 deletions(-)

Reviewed-by: Simon Glass <sjg at chromium.org>


More information about the U-Boot mailing list