diff options
| author | seteiro <[email protected]> | 2026-11-12 14:13:20 +0800 |
|---|---|---|
| committer | Rbb666 <[email protected]> | 2026-11-13 09:28:40 +0800 |
| commit | bf56b87f5d542dc5f9e5a7e268b77aa13c9dac74 (patch) | |
| tree | c815dca33d31e81eee58b75e1779dfd96242a3f5 | |
| parent | fddf97eaa140fc37f18b85b06a0d7ba77046b90d (diff) | |
[drivers][ofw] bound fdt_unflatten_single nest depth
| -rw-r--r-- | components/drivers/ofw/fdt.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/components/drivers/ofw/fdt.c b/components/drivers/ofw/fdt.c index dfbd55bc5b..577a5f9c42 100644 --- a/components/drivers/ofw/fdt.c +++ b/components/drivers/ofw/fdt.c @@ -979,6 +979,10 @@ rt_err_t rt_fdt_unflatten(void) err = err ? : ofw_phandle_hash_reset(_phandle_min, _phandle_max); } + else + { + err = -RT_ERROR; + } } else { @@ -1081,6 +1085,13 @@ static rt_err_t fdt_unflatten_single(struct rt_ofw_node *np, int node_off) if (node_off >= 0) { + if (depth >= OFW_NODE_MAX_DEPTH) + { + LOG_E("DTB node depth exceeds limit %d", OFW_NODE_MAX_DEPTH); + err = -RT_EINVAL; + break; + } + parent = np; np_stack[depth++] = np; |
