On Thu, May 07, 2026 at 06:06:03PM +0800, Guangshuo Li wrote:
> imx8qxp_pxl2dpi_get_available_ep_from_port() returns ERR_PTR()
> on errors. imx8qxp_pxl2dpi_find_next_bridge() stores its return
> value in a __free(device_node) variable before checking IS_ERR().
> When the function returns on the error path, the cleanup action calls
> of_node_put() on the ERR_PTR() value.
> 
> Do not let a device_node cleanup variable hold error pointers. Change
> imx8qxp_pxl2dpi_get_available_ep_from_port() to return an int and pass
> the endpoint node through an output argument. Initialize the output
> argument to NULL so callers hold either NULL on error paths or a valid
> device_node pointer on successful path.
> 
> Fixes: ceea3f7806a10 ("drm/bridge: imx8qxp-pxl2dpi: simplify put of 
> device_node pointers")
> Cc: [email protected]
> Reviewed-by: Liu Ying <[email protected]>
> Signed-off-by: Guangshuo Li <[email protected]>
> ---
> v7:
>   - Rephrase the commit message sentence about output argument
>     initialization as suggested by Liu Ying.
>   - Drop the unnecessary sentence about keeping explicit of_node_put()
>     usage.
>   - Add Liu Ying's Reviewed-by tag.
>   - No code changes.
> 
> v6:
>   - Change imx8qxp_pxl2dpi_get_available_ep_from_port() to return int
>     and pass the endpoint through an output argument.
>   - Keep using __free(device_node) in imx8qxp_pxl2dpi_find_next_bridge().
>   - Keep ep initialized to NULL in imx8qxp_pxl2dpi_find_next_bridge()
>     to satisfy the __free pointer initialization requirement.
>   - Do not add cleanup action usage in
>     imx8qxp_pxl2dpi_get_available_ep_from_port() or
>     imx8qxp_pxl2dpi_set_pixel_link_sel().
> 
> v5:
>   - Make the fix minimal for stable by avoiding __free(device_node)
>     for the endpoint node in imx8qxp_pxl2dpi_find_next_bridge().
>   - Keep imx8qxp_pxl2dpi_get_available_ep_from_port() unchanged.
>   - Do not change imx8qxp_pxl2dpi_set_pixel_link_sel().
>   - Drop Frank's Reviewed-by tag due to the implementation change.
> 
> v4:
>   - Drop the sentence mentioning the custom static analysis tool.
>   - Add Frank's Reviewed-by tag.
>   - No functional code changes.
> 
> v3:
>   - Do not change DEFINE_FREE(device_node, ...).
>   - Fix the driver pattern by making
>     imx8qxp_pxl2dpi_get_available_ep_from_port() return an int and
>     pass the endpoint via an output argument.
>   - Update both callers so __free(device_node) never holds ERR_PTR().
> 
> v2:
>   - Fix DEFINE_FREE(device_node, ...) directly.
> 
>  drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c | 40 +++++++++++---------
>  1 file changed, 23 insertions(+), 17 deletions(-)

Applied to misc/kernel.git (drm-misc-fixes), thanks!

-- 
Regards,
Liu Ying

Reply via email to