fdtdec: only create phandle if caller wants it in

A patch from »fdtdec: protect against another NULL phandlep in« in state Mainline for u-boot

From: Heiko Stuebner <heiko@...> Date: Tue, 8 Oct 2019 01:06:24 +0200

Commit-Message

The phandlep pointer returning the phandle to the caller is optional and if it is not set when calling fdtdec_add_reserved_memory() it is highly likely that the caller is not interested in a phandle to the created reserved-memory area and really just wants that area added. So just don't create a phandle in that case. Signed-off-by: Heiko Stuebner <heiko@...>

Patch-Comment

lib/fdtdec.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)

Statistics

  • 9 lines added
  • 7 lines removed

Changes

--------------------------------- lib/fdtdec.c ---------------------------------
index 17455c5506..39e87e89c9 100644
@@ -1393,13 +1393,15 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename,
if (node < 0)
return node;
- err = fdt_generate_phandle(blob, &phandle);
- if (err < 0)
- return err;
-
- err = fdtdec_set_phandle(blob, node, phandle);
- if (err < 0)
- return err;
+ if (phandlep) {
+ err = fdt_generate_phandle(blob, &phandle);
+ if (err < 0)
+ return err;
+
+ err = fdtdec_set_phandle(blob, node, phandle);
+ if (err < 0)
+ return err;
+ }
/* store one or two address cells */
if (na > 1)
 
 

Recent Patches

About Us

Sed lacus. Donec lectus. Nullam pretium nibh ut turpis. Nam bibendum. In nulla tortor, elementum vel, tempor at, varius non, purus. Mauris vitae nisl nec metus placerat consectetuer.

Read More...