Re: [PATCH v5 1/2] RFC: libfdt: Copy the struct region in fdt_resize()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Sat, Jul 07, 2018 at 01:57:19PM -0600, Simon Glass wrote:
> At present this function appears to copy only the data before the struct
> region and the data in the string region. It does not seem to copy the
> struct region itself.
> 
> >From the arguments of this function it seems that it should support fdt
> and buf being different. This patch attempts to fix this problem.
> 
> Signed-off-by: Simon Glass <sjg@xxxxxxxxxxxx>
> ---
> 
> Changes in v5:
> - Add new patch to copy the struct region in fdt_resize()

Ouch.  This was a pretty unsubtle bug to have been there all along.

This inspired me to make a testcase which would actually catch this,
and that in turn found an additional bug.  I've merged this patch
along with the new test and extra bugfix.

> 
> Changes in v4: None
> Changes in v3: None
> 
>  libfdt/fdt_sw.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libfdt/fdt_sw.c b/libfdt/fdt_sw.c
> index 178b365..024f4d8 100644
> --- a/libfdt/fdt_sw.c
> +++ b/libfdt/fdt_sw.c
> @@ -170,7 +170,7 @@ int fdt_resize(void *fdt, void *buf, int bufsize)
>  
>  	FDT_SW_PROBE(fdt);
>  
> -	headsize = fdt_off_dt_struct(fdt);
> +	headsize = fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt);
>  	tailsize = fdt_size_dt_strings(fdt);
>  
>  	if ((headsize + tailsize) > bufsize)

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux