Skip to content

Commit 8537a70

Browse files
zijun-hurobherring
authored andcommitted
of: Correct element count for two arrays in API of_parse_phandle_with_args_map()
of_parse_phandle_with_args_map() defines array @dummy_mask and @dummy_pass these two arrays only need @MAX_PHANDLE_ARGS elements separately, but they actually have (@MAX_PHANDLE_ARGS + 1) elements, One extra element doesn't hurt anything except for some stack usage. Fix by using (@MAX_PHANDLE_ARGS - 1) as max element index in initializer. Signed-off-by: Zijun Hu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Rob Herring (Arm) <[email protected]>
1 parent 81dfedd commit 8537a70

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/of/base.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,8 +1448,8 @@ int of_parse_phandle_with_args_map(const struct device_node *np,
14481448
char *pass_name __free(kfree) = kasprintf(GFP_KERNEL, "%s-map-pass-thru", stem_name);
14491449
struct device_node *cur, *new = NULL;
14501450
const __be32 *map, *mask, *pass;
1451-
static const __be32 dummy_mask[] = { [0 ... MAX_PHANDLE_ARGS] = cpu_to_be32(~0) };
1452-
static const __be32 dummy_pass[] = { [0 ... MAX_PHANDLE_ARGS] = cpu_to_be32(0) };
1451+
static const __be32 dummy_mask[] = { [0 ... (MAX_PHANDLE_ARGS - 1)] = cpu_to_be32(~0) };
1452+
static const __be32 dummy_pass[] = { [0 ... (MAX_PHANDLE_ARGS - 1)] = cpu_to_be32(0) };
14531453
__be32 initial_match_array[MAX_PHANDLE_ARGS];
14541454
const __be32 *match_array = initial_match_array;
14551455
int i, ret, map_len, match;

0 commit comments

Comments
 (0)