mbox series

[v2,0/2] lmb: Fix reserving the same region multiple times

Message ID 20241211021703.2333-1-semen.protsenko@linaro.org
Headers show
Series lmb: Fix reserving the same region multiple times | expand

Message

Sam Protsenko Dec. 11, 2024, 2:17 a.m. UTC
This series is intended to be picked up for the v2025.01 release.

Since commit 1d9aa4a283da ("lmb: Fix the allocation of overlapping
memory areas with !LMB_NONE") the lmb_add_region_flags() returns -1 when
the caller tries to add the already existing region with !LMB_NONE
flags (it was returning 0 before that patch). That causes
boot_fdt_reserve_region() function to print erroneous error messages
when it's called consequently more than one time.

Make lmb_add_region_flags() return -EEXIST when the already added region
with !LMB_NONE flags is being added, and then check that error code in
boot_fdt_reserve_region() to avoid printing the misleading error
messages.

This series fixes all 3 found cases (discussed at [1]) for the false
positive error messages. All unit tests pass in sandbox U-Boot.

Changes in v2:
  - Split the original series by two separate series (cleanups will be
    sent out as a different one)
  - Collected all R-b and A-b tags from review
  - Patch #1: Removed the check for exactly the same region, and return
    -EEXIST in the branch handling overlapping regions instead
  - Reworded the commit messages slightly

[1] https://lists.denx.de/pipermail/u-boot/2024-December/574123.html

Sam Protsenko (2):
  lmb: Return -EEXIST in lmb_add_region_flags() if region already added
  boot: fdt: Handle already reserved memory in boot_fdt_reserve_region()

 boot/image-fdt.c |  2 +-
 lib/lmb.c        | 26 +++++++++++++-------------
 test/lib/lmb.c   |  2 +-
 3 files changed, 15 insertions(+), 15 deletions(-)

Comments

Michal Simek Dec. 12, 2024, 2:40 p.m. UTC | #1
st 11. 12. 2024 v 3:17 odesílatel Sam Protsenko
<semen.protsenko@linaro.org> napsal:
>
> This series is intended to be picked up for the v2025.01 release.
>
> Since commit 1d9aa4a283da ("lmb: Fix the allocation of overlapping
> memory areas with !LMB_NONE") the lmb_add_region_flags() returns -1 when
> the caller tries to add the already existing region with !LMB_NONE
> flags (it was returning 0 before that patch). That causes
> boot_fdt_reserve_region() function to print erroneous error messages
> when it's called consequently more than one time.
>
> Make lmb_add_region_flags() return -EEXIST when the already added region
> with !LMB_NONE flags is being added, and then check that error code in
> boot_fdt_reserve_region() to avoid printing the misleading error
> messages.
>
> This series fixes all 3 found cases (discussed at [1]) for the false
> positive error messages. All unit tests pass in sandbox U-Boot.
>
> Changes in v2:
>   - Split the original series by two separate series (cleanups will be
>     sent out as a different one)
>   - Collected all R-b and A-b tags from review
>   - Patch #1: Removed the check for exactly the same region, and return
>     -EEXIST in the branch handling overlapping regions instead
>   - Reworded the commit messages slightly
>
> [1] https://lists.denx.de/pipermail/u-boot/2024-December/574123.html
>
> Sam Protsenko (2):
>   lmb: Return -EEXIST in lmb_add_region_flags() if region already added
>   boot: fdt: Handle already reserved memory in boot_fdt_reserve_region()
>
>  boot/image-fdt.c |  2 +-
>  lib/lmb.c        | 26 +++++++++++++-------------
>  test/lib/lmb.c   |  2 +-
>  3 files changed, 15 insertions(+), 15 deletions(-)
>
> --
> 2.39.5
>

Tested-by: Michal Simek <michal.simek@amd.com>

Thanks,
Michal
Tom Rini Dec. 12, 2024, 7:18 p.m. UTC | #2
On Tue, 10 Dec 2024 20:17:00 -0600, Sam Protsenko wrote:

> This series is intended to be picked up for the v2025.01 release.
> 
> Since commit 1d9aa4a283da ("lmb: Fix the allocation of overlapping
> memory areas with !LMB_NONE") the lmb_add_region_flags() returns -1 when
> the caller tries to add the already existing region with !LMB_NONE
> flags (it was returning 0 before that patch). That causes
> boot_fdt_reserve_region() function to print erroneous error messages
> when it's called consequently more than one time.
> 
> [...]

Applied to u-boot/master, thanks!