From mboxrd@z Thu Jan 1 00:00:00 1970 From: Simon Glass Date: Sat, 22 Jun 2019 20:09:20 +0100 Subject: [U-Boot] [PATCH PATCH v3 03/12] spl: fit: allocate a temporary buffer to load the overlays In-Reply-To: <20190523103912.3790-4-jjhiblot@ti.com> References: <20190523103912.3790-1-jjhiblot@ti.com> <20190523103912.3790-4-jjhiblot@ti.com> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Jean-Jacques, On Thu, 23 May 2019 at 11:39, Jean-Jacques Hiblot wrote: > > If the node describing an overlay does not specify a load address, it will > be loaded at the address previously used. > Fixing it by allocating a temporary 64kB region that will be used as a > default load address. > > Signed-off-by: Jean-Jacques Hiblot > --- > > Changes in v3: None > Changes in v2: None > > common/spl/spl_fit.c | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c > index c1c982f002..b521ee68e6 100644 > --- a/common/spl/spl_fit.c > +++ b/common/spl/spl_fit.c > @@ -9,6 +9,7 @@ > #include > #include > #include should go at end > +#include > #include > > #ifndef CONFIG_SYS_BOOTM_LEN > @@ -302,6 +303,16 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image, > spl_image->fdt_addr = (void *)image_info.load_addr; > #if !CONFIG_IS_ENABLED(FIT_IMAGE_TINY) > #if defined(CONFIG_SPL_LOAD_FIT_APPLY_OVERLAY) > + void *tmpbuffer; > + /* > + * allocate 64kB of memory. This will be used to store the DT overlay 64KB > + * before it is applied. It may not be used depending on how the > + * overlay is stored. > + */ > + tmpbuffer = malloc(64 * 1024); > + if (!tmpbuffer) > + debug("%s: unable to allocate space for overlays\n", __func__); Need to return an error here I think > + > for (; ; index++) { > node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP, index); > if (node < 0) { > @@ -309,6 +320,7 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image, > return 0; > } > > + image_info.load_addr = (ulong)tmpbuffer; > ret = spl_load_fit_image(info, sector, fit, base_offset, node, > &image_info); > if (ret < 0) > @@ -327,6 +339,8 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image, > debug("%s: DT overlay %s applied\n", __func__, > fit_get_name(fit, node, NULL)); > } > + if (tmpbuffer) > + free(tmpbuffer); Is this buffer freed if there is an error? > #endif > /* Try to make space, so we can inject details on the loadables */ > ret = fdt_shrink_to_minimum(spl_image->fdt_addr, 8192); > -- > 2.17.1 > Regards, Simon