Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Yuansheng Yang <0xbeac@gmail.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Michal Simek <michal.simek@amd.com>
Cc: linux-media@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: [PATCH] media: xilinx-vipp: fix double fwnode_handle_put() in xvip_graph_parse_one()
Date: Sat,  5 Dec 2026 01:07:16 +0800	[thread overview]
Message-ID: <20261204170716.1294557-1-0xbeac@gmail.com> (raw)

fwnode_graph_get_next_endpoint() already drops the reference on its
previous endpoint `ep`, and the `err_notifier_cleanup:` path also calls
fwnode_handle_put(ep). Calling fwnode_handle_put(ep) inside the loop
body therefore drops `ep`'s reference a second time both on the next
iteration and on the v4l2_async_nf_add_fwnode() error path.

On OF graphs this underflows the endpoint node's refcount on overlay
teardown or repeated probes (deadlocking on devtree_lock when
of_node_release() formats %pOF from inside of_get_next_child()):

  refcount_t: underflow; use-after-free.
  Call Trace:
   kobject_put
   of_changeset_destroy
   free_overlay_changeset
   of_overlay_remove

  Call Trace:
   of_get_parent
   ...
   of_node_release
   of_get_next_child
   of_graph_get_next_endpoint
   xvip_graph_parse_one
   xvip_composite_probe

Drop the redundant fwnode_handle_put(ep) inside the loop.

Fixes: d079f94c9046 ("media: platform: Switch to v4l2_async_notifier_add_subdev")
Cc: stable@vger.kernel.org
Signed-off-by: Yuansheng Yang <0xbeac@gmail.com>
---
Compiled with W=1 on x86_64 (0 warnings) and verified on v7.4-rc5 with a
DT overlay probing xilinx-video: before the fix, a single probe + overlay
removal hit refcount_t underflow and repeated rebinds hit the devtree_lock
stall inside xvip_composite_probe(); after the fix, 10 overlay cycles x 5
probes passed with 0 errors or warnings.

 drivers/media/platform/xilinx/xilinx-vipp.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c
index 786e4f2e6..d997fed57 100644
--- a/drivers/media/platform/xilinx/xilinx-vipp.c
+++ b/drivers/media/platform/xilinx/xilinx-vipp.c
@@ -353,8 +353,6 @@ static int xvip_graph_parse_one(struct xvip_composite_device *xdev,
 			goto err_notifier_cleanup;
 		}
 
-		fwnode_handle_put(ep);
-
 		/* Skip entities that we have already processed. */
 		if (remote == of_fwnode_handle(xdev->dev->of_node) ||
 		    xvip_graph_find_entity(xdev, remote)) {
-- 
2.53.0


                 reply	other threads:[~2026-12-04 17:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261204170716.1294557-1-0xbeac@gmail.com \
    --to=0xbeac@gmail.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=michal.simek@amd.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox