2020-01-21 23:30:50

by Aditya Pakki

[permalink] [raw]
Subject: [PATCH] x86/platform/olpc: Fix the error handling of memblock_alloc failure

In case of an error in memblock_alloc, the code calls both panic and
BUG_ON. Revert the error handling to BUG_ON.

Fixes: 8a7f97b902f4 (add checks for the return value of memblock_alloc*())
Signed-off-by: Aditya Pakki <[email protected]>
---
arch/x86/platform/olpc/olpc_dt.c | 3 ---
1 file changed, 3 deletions(-)

diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
index 26d1f6693789..92d5ce1232ab 100644
--- a/arch/x86/platform/olpc/olpc_dt.c
+++ b/arch/x86/platform/olpc/olpc_dt.c
@@ -137,9 +137,6 @@ void * __init prom_early_alloc(unsigned long size)
* wasted bootmem) and hand off chunks of it to callers.
*/
res = memblock_alloc(chunk_size, SMP_CACHE_BYTES);
- if (!res)
- panic("%s: Failed to allocate %zu bytes\n", __func__,
- chunk_size);
BUG_ON(!res);
prom_early_allocated += chunk_size;
memset(res, 0, chunk_size);
--
2.20.1


2020-01-22 07:43:25

by Lubomir Rintel

[permalink] [raw]
Subject: Re: [PATCH] x86/platform/olpc: Fix the error handling of memblock_alloc failure

On Tue, Jan 21, 2020 at 05:28:16PM -0600, Aditya Pakki wrote:
> In case of an error in memblock_alloc, the code calls both panic and
> BUG_ON. Revert the error handling to BUG_ON.
>
> Fixes: 8a7f97b902f4 (add checks for the return value of memblock_alloc*())
> Signed-off-by: Aditya Pakki <[email protected]>

Reviewed-by: Lubomir Rintel <[email protected]>

Thank you
Lubo

> ---
> arch/x86/platform/olpc/olpc_dt.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
> index 26d1f6693789..92d5ce1232ab 100644
> --- a/arch/x86/platform/olpc/olpc_dt.c
> +++ b/arch/x86/platform/olpc/olpc_dt.c
> @@ -137,9 +137,6 @@ void * __init prom_early_alloc(unsigned long size)
> * wasted bootmem) and hand off chunks of it to callers.
> */
> res = memblock_alloc(chunk_size, SMP_CACHE_BYTES);
> - if (!res)
> - panic("%s: Failed to allocate %zu bytes\n", __func__,
> - chunk_size);
> BUG_ON(!res);
> prom_early_allocated += chunk_size;
> memset(res, 0, chunk_size);
> --
> 2.20.1
>