2013-08-29 11:41:44

by Grant Likely

[permalink] [raw]
Subject: [PATCH] of: Fix missing memory initialization on FDT unflattening

Any calls to dt_alloc() need to be zeroed. This is a temporary fix, but
the allocation function itself needs to zero memory before returning
it. This is a follow up to patch 9e4012752, "of: fdt: fix memory
initialization for expanded DT" which fixed one call site but missed
another.

Signed-off-by: Grant Likely <[email protected]>
Cc: [email protected]
Cc: Wladislav Wiebe <[email protected]>
---
drivers/of/base.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 5c54279..bf8432f 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1629,6 +1629,7 @@ void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align))
ap = dt_alloc(sizeof(*ap) + len + 1, 4);
if (!ap)
continue;
+ memset(ap, 0, sizeof(*ap) + len + 1);
ap->alias = start;
of_alias_add(ap, np, id, start, len);
}
--
1.8.1.2


2013-08-29 16:49:22

by Wladislav Wiebe

[permalink] [raw]
Subject: Re: [PATCH] of: Fix missing memory initialization on FDT unflattening

On 29/08/13 13:41, Grant Likely wrote:
> Any calls to dt_alloc() need to be zeroed. This is a temporary fix, but
> the allocation function itself needs to zero memory before returning
> it. This is a follow up to patch 9e4012752, "of: fdt: fix memory
> initialization for expanded DT" which fixed one call site but missed
> another.

Acked-by: Wladislav Wiebe <[email protected]>

>
> Signed-off-by: Grant Likely <[email protected]>
> Cc: [email protected]
> Cc: Wladislav Wiebe <[email protected]>
> ---
> drivers/of/base.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 5c54279..bf8432f 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -1629,6 +1629,7 @@ void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align))
> ap = dt_alloc(sizeof(*ap) + len + 1, 4);
> if (!ap)
> continue;
> + memset(ap, 0, sizeof(*ap) + len + 1);
> ap->alias = start;
> of_alias_add(ap, np, id, start, len);
> }
>