From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: drm/bridge: imx8qxp-pxl2dpi: avoid ERR_PTR with device_node cleanup Date: Tue, 05 May 2026 08:50:48 +1000 Message-ID: In-Reply-To: <20260502115528.530401-1-lgs201920130244@gmail.com> References: <20260502115528.530401-1-lgs201920130244@gmail.com> <20260502115528.530401-1-lgs201920130244@gmail.com> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Patch Review **Bug analysis:** Correct. The existing code at line 267-268 of the current= tree: ```c struct device_node *ep __free(device_node) =3D imx8qxp_pxl2dpi_get_available_ep_from_port(p2d, 1); ``` stores an `ERR_PTR()` in a `__free(device_node)` variable. Since `DEFINE_FR= EE(device_node, ...)` is defined as: ```c DEFINE_FREE(device_node, struct device_node *, if (_T) of_node_put(_T)) ``` an `ERR_PTR()` passes the `if (_T)` check (it's non-NULL) and `of_node_put(= )` is called on a bogus error-encoding pointer. **Fix approach (helper refactoring):** Clean and idiomatic. The function si= gnature change from: ```c static struct device_node * imx8qxp_pxl2dpi_get_available_ep_from_port(struct imx8qxp_pxl2dpi *p2d, u32 port_id) ``` to: ```c static int imx8qxp_pxl2dpi_get_available_ep_from_port(struct imx8qxp_pxl2dpi *p2d, u32 port_id, struct device_node **ep) ``` is a reasonable pattern. The output parameter `*ep` is initialized to `NULL= ` at the top, and only set to a valid node on success. **Helper function internals:** The `port` variable is now also managed with= `__free(device_node)`: ```c struct device_node *port __free(device_node) =3D of_graph_get_port_by_id(p2d->dev->of_node, port_id); ``` This is correct =E2=80=94 `of_graph_get_port_by_id()` returns `NULL` on fai= lure (not `ERR_PTR()`), so the cleanup is safe and eliminates the old `goto= out` / `of_node_put(port)` pattern. **Caller `imx8qxp_pxl2dpi_find_next_bridge()`:** Correctly updated: ```c struct device_node *ep __free(device_node) =3D NULL; int ret; ret =3D imx8qxp_pxl2dpi_get_available_ep_from_port(p2d, 1, &ep); if (ret) return ret; ``` The `ep` is initialized to `NULL`, so if the function fails (returning a ne= gative error), `ep` remains `NULL` and the `__free(device_node)` cleanup is= a safe no-op. **Caller `imx8qxp_pxl2dpi_set_pixel_link_sel()`:** Also correctly updated. = Additionally, this caller now uses `__free(device_node)` for `ep` where it = previously used manual `of_node_put()`. The `goto out` / manual cleanup pat= tern is removed, and the function now returns early on errors: ```c ret =3D of_graph_parse_endpoint(ep, &endpoint); if (ret) { DRM_DEV_ERROR(p2d->dev, "failed to parse endpoint of port@0: %d\n", ret); return ret; } p2d->pl_sel =3D endpoint.id; return 0; ``` This is a nice improvement =E2=80=94 it makes the second caller consistent = with the first and simplifies the control flow. **Minor nit =E2=80=94 Fixes tag format:** ``` Fixes: ceea3f7806a10 ("drm/bridge: imx8qxp-pxl2dpi: ...") ``` The abbreviated SHA `ceea3f7806a10` is 13 hex characters. The kernel conven= tion (`checkpatch.pl`) expects exactly 12. Should be `ceea3f7806a1`. This i= s cosmetic and wouldn't block acceptance, but is worth mentioning for a cle= an commit log. **Overall:** The patch correctly identifies and fixes a real bug, the appro= ach is clean, both callers are properly updated, and the commit message is = clear and well-written. Reviewed-by-worthy with the optional Fixes tag nit. --- Generated by Claude Code Patch Reviewer