Skip to content

Commit 8041e83

Browse files
committed
Validate qman portal cell-index
F/1102
1 parent d1b488f commit 8041e83

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

tools/fdt-parser/fdt-parser.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,18 @@ static int fdt_test(void* fdt)
192192
off = fdt_node_offset_by_compatible(fdt, -1, "fsl,qman-portal");
193193
while (off != -FDT_ERR_NOTFOUND) {
194194
const int *ci = fdt_getprop(fdt, off, "cell-index", NULL);
195+
uint32_t portal_idx;
195196
uint32_t liodns[2];
196197
if (!ci)
197198
break;
198-
i = fdt32_to_cpu(*ci);
199+
portal_idx = fdt32_to_cpu(*ci);
200+
if (portal_idx >= QMAN_NUM_PORTALS) {
201+
printf("FDT: Invalid qman-portal cell-index %u at %d\n",
202+
portal_idx, off);
203+
ret = -FDT_ERR_BADSTRUCTURE;
204+
goto exit;
205+
}
206+
i = (int)portal_idx;
199207

200208
liodns[0] = qp_info[i].dliodn;
201209
liodns[1] = qp_info[i].fliodn;

0 commit comments

Comments
 (0)