From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793801889; b=TWWI1Iw4BmEAaxVBvYk3d2SNlkpRPjj4CUUcwpQ+jQsVn/GwCBqPs+CPzkQoviQI/35G T0oOsVTG85oHCRau1+UkUjUDGZva5UI8wQNwH8tPs2BQa/37pK/ac2H8c3MHI4oAYoPRj kkvGloqJiLYthozisxO5k0TZ3pI7+Q/5QVHafjJAGW5RvqZKz06kLwynmPxiNfyakZmWP 5SGwSkVRNFtMen1e/DMfXZLddznQV/gCqaDeJ1OQaxHx78bQp5z5uGeAyt0srDapL+S3t wMbDLi+/Z6mWEhomKVKL7zZJ6TAHHvPLt9cakD1QUPv/xwq+SGPNw8UlKBEk/8fs8sA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793801889; h=Received:DKIM-Signature:Subject:To:Cc:From:Date:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=8zdxlzzQ/HNwnZn8aeUjwlLuB2cfmRbuxdoxKnVBhgk=; b=e3KfJ0rVROGDg/iMcYT82/Yt881/2netny++Su6fXc+L7XP2NiNjk9gB2MB9wRECNWZt l7uBkqHoUwYqwS6W9XoLaYcZR1Z9bxMvYBfkurKE1sOCHgpchRFiXukbCsEHpkTK3UUX0 ZYk2sR1FWg3LnbXs+18Djf/XX/f1C3zzOpktAs7M9cjrhr9NMR+faFIwRC2DRNWP082pI RoD9LL0yQ61BjL8uy/wWI3GBpCjpLJUndBH+8jNV3rS98SiYqHtq+9g3zWjtAPvrjMbxt OAsz0pEsj2br9Ccf3jm7yqpKf5HMjIT57fthDr6jlE92/dz9HzmI5J4Us1Br9rgC0uw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=LBrlPVNm; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A51C1606A32D for ; Wed, 4 Nov 2026 14:18:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=LBrlPVNm Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E5A21F000C1; Wed, 4 Nov 2026 14:18:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1793801888; bh=8zdxlzzQ/HNwnZn8aeUjwlLuB2cfmRbuxdoxKnVBhgk=; h=Subject:To:Cc:From:Date; b=LBrlPVNm1dqTlhqIy1hCXjACr5E56hUuUkyEB8s7f0QlAPRc0ipFWqgrSpx+vWy41 5zWR6cS2OpyNV+NU6q9LfbPQ66M7yrfOhzjjV8P9hTC2friueb4ssnuf4i5ooRfaFF SP0x6FJWDAemhKsLQ/Slj486jIc06iQTarIjNaX0= Subject: FAILED: patch "[PATCH] media: microchip-isc: take a reference on the parsed" failed to apply to 6.1-stable tree To: balakrishnan.s@microchip.com,ehristev@kernel.org,hverkuil+cisco@kernel.org Cc: From: Date: Wed, 04 Nov 2026 15:17:57 +0100 Message-ID: <2026110457-banking-figurine-e1c2@gregkh> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.1-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y git checkout FETCH_HEAD git cherry-pick -x f2eb2fd388bf3f1959556a326e797cacca341c86 # git commit -s git send-email --to '' --in-reply-to '2026110457-banking-figurine-e1c2@gregkh' --subject-prefix 'PATCH 6.1.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From f2eb2fd388bf3f1959556a326e797cacca341c86 Mon Sep 17 00:00:00 2001 From: Balakrishnan Sambath Date: Mon, 17 Aug 2026 12:21:59 +0530 Subject: [PATCH] media: microchip-isc: take a reference on the parsed endpoints for_each_endpoint_of_node() drops the reference on the current node as it advances. xisc_parse_dt() and isc_parse_dt() store the node in subdev_entity->epn and release it later with of_node_put(), but never took their own reference, so the stored pointer refers to an already-released node. This underflows the refcount and can use-after-free, reachable through the camera device tree overlay. Take a reference with of_node_get() when storing the node, and drop it in microchip_isc_subdev_cleanup() so the entities the bind loop never reaches on an early exit do not leak it. Fixes: c9aa973884a1 ("media: atmel: atmel-isc: add microchip-xisc driver") Fixes: d6701f13bd07 ("media: atmel: Use v4l2_async_notifier_add_fwnode_remote_subdev") Cc: stable@vger.kernel.org Signed-off-by: Balakrishnan Sambath Reviewed-by: Eugen Hristev Signed-off-by: Hans Verkuil diff --git a/drivers/media/platform/microchip/microchip-isc-base.c b/drivers/media/platform/microchip/microchip-isc-base.c index eebbcb28a7ee..ca4f3b5f58aa 100644 --- a/drivers/media/platform/microchip/microchip-isc-base.c +++ b/drivers/media/platform/microchip/microchip-isc-base.c @@ -1853,6 +1853,12 @@ void microchip_isc_subdev_cleanup(struct isc_device *isc) list_for_each_entry(subdev_entity, &isc->subdev_entities, list) { v4l2_async_nf_unregister(&subdev_entity->notifier); v4l2_async_nf_cleanup(&subdev_entity->notifier); + /* + * Release the endpoint reference taken while parsing. It is + * NULL for entities the bind loop already consumed, so this + * only drops the ones left over on an early exit. + */ + of_node_put(subdev_entity->epn); } INIT_LIST_HEAD(&isc->subdev_entities); diff --git a/drivers/media/platform/microchip/microchip-sama5d2-isc.c b/drivers/media/platform/microchip/microchip-sama5d2-isc.c index 25d241b4c66a..18e1ec0b94fa 100644 --- a/drivers/media/platform/microchip/microchip-sama5d2-isc.c +++ b/drivers/media/platform/microchip/microchip-sama5d2-isc.c @@ -357,28 +357,30 @@ static int isc_parse_dt(struct device *dev, struct isc_device *isc) struct device_node *epn; struct isc_subdev_entity *subdev_entity; unsigned int flags; + int ret; INIT_LIST_HEAD(&isc->subdev_entities); for_each_endpoint_of_node(np, epn) { struct v4l2_fwnode_endpoint v4l2_epn = { .bus_type = 0 }; - int ret; ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(epn), &v4l2_epn); if (ret) { - of_node_put(epn); dev_err(dev, "Could not parse the endpoint\n"); - return -EINVAL; + of_node_put(epn); + ret = -EINVAL; + goto err_cleanup; } subdev_entity = devm_kzalloc(dev, sizeof(*subdev_entity), GFP_KERNEL); if (!subdev_entity) { of_node_put(epn); - return -ENOMEM; + ret = -ENOMEM; + goto err_cleanup; } - subdev_entity->epn = epn; + subdev_entity->epn = of_node_get(epn); flags = v4l2_epn.bus.parallel.flags; @@ -399,6 +401,11 @@ static int isc_parse_dt(struct device *dev, struct isc_device *isc) } return 0; + +err_cleanup: + list_for_each_entry(subdev_entity, &isc->subdev_entities, list) + of_node_put(subdev_entity->epn); + return ret; } static int microchip_isc_probe(struct platform_device *pdev) diff --git a/drivers/media/platform/microchip/microchip-sama7g5-isc.c b/drivers/media/platform/microchip/microchip-sama7g5-isc.c index 28d975002476..07cfe1109ff0 100644 --- a/drivers/media/platform/microchip/microchip-sama7g5-isc.c +++ b/drivers/media/platform/microchip/microchip-sama7g5-isc.c @@ -341,6 +341,7 @@ static int xisc_parse_dt(struct device *dev, struct isc_device *isc) struct isc_subdev_entity *subdev_entity; unsigned int flags; bool mipi_mode; + int ret; INIT_LIST_HEAD(&isc->subdev_entities); @@ -348,23 +349,24 @@ static int xisc_parse_dt(struct device *dev, struct isc_device *isc) for_each_endpoint_of_node(np, epn) { struct v4l2_fwnode_endpoint v4l2_epn = { .bus_type = 0 }; - int ret; ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(epn), &v4l2_epn); if (ret) { - of_node_put(epn); dev_err(dev, "Could not parse the endpoint\n"); - return -EINVAL; + of_node_put(epn); + ret = -EINVAL; + goto err_cleanup; } subdev_entity = devm_kzalloc(dev, sizeof(*subdev_entity), GFP_KERNEL); if (!subdev_entity) { of_node_put(epn); - return -ENOMEM; + ret = -ENOMEM; + goto err_cleanup; } - subdev_entity->epn = epn; + subdev_entity->epn = of_node_get(epn); flags = v4l2_epn.bus.parallel.flags; @@ -388,6 +390,11 @@ static int xisc_parse_dt(struct device *dev, struct isc_device *isc) } return 0; + +err_cleanup: + list_for_each_entry(subdev_entity, &isc->subdev_entities, list) + of_node_put(subdev_entity->epn); + return ret; } static int microchip_xisc_probe(struct platform_device *pdev)