Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dddc33e5 authored by Gavin Shan's avatar Gavin Shan Committed by Rob Herring
Browse files

drivers/of: Fix build warning in populate_node()



Function populate_node() is used to unflatten FDT blob to device
tree. It supports maximal 64 level of device nodes. There is one
array @fpsizes[64] tracking the full name length of last unflattened
device node in the corresponding level (index of element in the
array - 1). Build warning is seen with CONFIG_FRAME_WARN=1024 like
below on ARM64 as Geert reported. The issue can be reproduced on
PPC64 as well.

  $ make drivers/of/fdt.o
  drivers/of/fdt.c:443:1: warning: the frame size of 1136 bytes is \
  larger than 1024 bytes [-Wframe-larger-than=]

This changes the data type of @fpsizes[i] from "unsigned long" to
"unsigned int" to avoid the build warning. The return value type
of populate_node() and its @fpsize argument is adjusted accordingly.
With this applied, 256 bytes saved from the stack frame on ARM64 and
PPC64 platforms and the above warning isn't seen.

Fixes: 50800082 ("drivers/of: Avoid recursively calling unflatten_dt_node()")
Reported-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: default avatarGavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: default avatarRob Herring <robh@kernel.org>
parent 78c44d91
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -264,11 +264,11 @@ static void populate_properties(const void *blob,
		*pprev = NULL;
}

static unsigned long populate_node(const void *blob,
static unsigned int populate_node(const void *blob,
				  int offset,
				  void **mem,
				  struct device_node *dad,
				   unsigned long fpsize,
				  unsigned int fpsize,
				  struct device_node **pnp,
				  bool dryrun)
{
@@ -397,7 +397,7 @@ static int unflatten_dt_nodes(const void *blob,
	struct device_node *root;
	int offset = 0, depth = 0;
#define FDT_MAX_DEPTH	64
	unsigned long fpsizes[FDT_MAX_DEPTH];
	unsigned int fpsizes[FDT_MAX_DEPTH];
	struct device_node *nps[FDT_MAX_DEPTH];
	void *base = mem;
	bool dryrun = !base;