Linux Remote Processor Subsystem development
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, Bjorn Andersson <andersson@kernel.org>,
	Mathieu Poirier <mathieu.poirier@linaro.org>,
	Uday Khare <udaykhare77@gmail.com>,
	linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH 07/10] remoteproc: qcom: Clear glink->node on allocation failure
Date: Mon, 23 Nov 2026 17:20:51 +0000	[thread overview]
Message-ID: <20261123172140.3547896-8-lee@kernel.org> (raw)
In-Reply-To: <20261123172140.3547896-1-lee@kernel.org>

When kstrdup_const() fails in qcom_add_glink_subdev(), the error path
drops the device-node reference via of_node_put(glink->node) and returns
before registering the GLINK subdevice, leaving glink->node non-NULL.
During subsequent teardown, qcom_remove_glink_subdev() checks
glink->node, calls rproc_remove_subdev() on an uninitialised list node
resulting in a NULL pointer dereference, and drops the device-node
reference a second time.

Reset glink->node to NULL when releasing the node reference so teardown
leaves an unregistered subdevice untouched.

Fixes: 44f4911ab8e6 ("remoteproc: qcom: Fix glink->node reference leak in qcom_add_glink_subdev")
Closes: https://sashiko.dev/#/bug/linux-eb8cc93d-8136-4bff-a5e7-3698dbe185ae
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/remoteproc/qcom_common.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c
index 5294e327f158..c53190f0c537 100644
--- a/drivers/remoteproc/qcom_common.c
+++ b/drivers/remoteproc/qcom_common.c
@@ -255,6 +255,7 @@ void qcom_add_glink_subdev(struct rproc *rproc, struct qcom_rproc_glink *glink,
 	glink->ssr_name = kstrdup_const(ssr_name, GFP_KERNEL);
 	if (!glink->ssr_name) {
 		of_node_put(glink->node);
+		glink->node = NULL;
 		return;
 	}
 
@@ -280,6 +281,7 @@ void qcom_remove_glink_subdev(struct rproc *rproc, struct qcom_rproc_glink *glin
 	rproc_remove_subdev(rproc, &glink->subdev);
 	kfree_const(glink->ssr_name);
 	of_node_put(glink->node);
+	glink->node = NULL;
 }
 EXPORT_SYMBOL_GPL(qcom_remove_glink_subdev);
 
-- 
2.56.1.750.gf70dc682cf-goog


  parent reply	other threads:[~2026-11-23 17:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 17:20 [PATCH 00/10] remoteproc: Assorted bug fixes across remoteproc core and drivers Lee Jones
2026-11-23 17:20 ` [PATCH 01/10] remoteproc: core: Fix integer overflow in rproc_check_carveout_da() Lee Jones
2026-11-23 17:20 ` [PATCH 02/10] remoteproc: k3: Fix integer overflow in k3_rproc_da_to_va() Lee Jones
2026-11-23 17:20 ` [PATCH 03/10] remoteproc: omap: Fix integer overflow in omap_rproc_da_to_va() Lee Jones
2026-11-23 17:20 ` [PATCH 04/10] remoteproc: elf_loader: Fix overflow in rproc_elf_load_segments() Lee Jones
2026-11-23 17:20 ` [PATCH 05/10] remoteproc: imx_rproc: Avoid stale mailbox pointers on request failure Lee Jones
2026-11-23 17:20 ` [PATCH 06/10] remoteproc: imx_rproc: Register SCU cleanup after resource acquisition Lee Jones
2026-11-23 17:20 ` Lee Jones [this message]
2026-11-23 17:20 ` [PATCH 08/10] remoteproc: qcom: Skip unregistering uninitialised SSR subdevice Lee Jones
2026-11-23 17:20 ` [PATCH 09/10] remoteproc: imx_dsp_rproc: Fix pointer stride in imx_dsp_rproc_memset() Lee Jones
2026-11-23 17:20 ` [PATCH 10/10] remoteproc: imx_dsp_rproc: Fix off-by-one bitmask for trailing bytes Lee Jones

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=20261123172140.3547896-8-lee@kernel.org \
    --to=lee@kernel.org \
    --cc=andersson@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=stable@vger.kernel.org \
    --cc=udaykhare77@gmail.com \
    /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