Claude review: drm/bridge: it6505: fix use-after-free in it6505_parse_dt()

Claude Code Review Bot
2026-04-12T01:30:02Z

Patch Review

**The identified bug is real.** In the original code:
```c
ep = of_graph_get_endpoint_by_regs(np, 0, 0);
of_node_put(ep);

if (ep) {
len = of_property_read_variable_u64_array(ep, /* use-after-free */
"link-frequencies",
&link_frequencies, 0, 1);
```
`of_node_put(ep)` is called before `ep` is used in `of_property_read_variable_u64_array()`. Moving the put after the last use of `ep` is the correct fix for this instance.

**Issue 1 — Unnecessary `of_node_put(ep)` in the `else` branch.** The patch adds:
```c
} else {
of_node_put(ep);
dev_err(dev, "error endpoint, use default");
```
The `else` branch is only entered when `ep == NULL`. `of_node_put(NULL)` is a no-op (it checks for NULL internally), so this call is dead code. It's harmless but misleading — it gives the impression that a real reference is being released. This should be removed.

**Issue 2 — Same bug exists at lines 3344–3353 (unfixed).** The exact same use-after-free pattern exists earlier in the function for the *first* endpoint lookup:
```c
ep = of_graph_get_endpoint_by_regs(np, 1, 0); /* line 3344 */
of_node_put(ep); /* line 3345 — too early! */

if (ep) {
len = it6505_get_data_lanes_count(ep, 1, 4); /* line 3348 — use-after-free */

if (len > 0 && len != 3) {
of_property_read_u32_array(ep, "data-lanes", /* line 3351 — use-after-free */
data_lanes, len);
```
Here `ep` is used in both `it6505_get_data_lanes_count()` and `of_property_read_u32_array()` after the refcount has already been dropped. A complete fix should address both instances. Since the commit message says "fix use-after-free in it6505_parse_dt()" and the Fixes tag references the commit that introduced *both* patterns, readers would expect both to be fixed.

**Recommendation:** Resubmit with both instances fixed, and drop the no-op `of_node_put(ep)` from the `else` branches. The fix for both should be the same: move `of_node_put(ep)` to inside the `if (ep)` block, after the last use of `ep`.