From: Sudeep Holla <sudeep.holla@kernel.org>
To: arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Cc: Cristian Marussi <cristian.marussi@arm.com>
Subject: [PATCH v4 12/16] firmware: arm_scmi: Fix OF node reference handling
Date: Wed, 08 Jul 2026 10:00:08 +0100 [thread overview]
Message-ID: <20260708-scmi_core_fixes-v4-12-53142cd60b63@kernel.org> (raw)
In-Reply-To: <20260708-scmi_core_fixes-v4-0-53142cd60b63@kernel.org>
SCMI devices store the DT node in dev.of_node through
device_set_node(), but that helper only assigns the fwnode and
of_node pointers without taking an OF node reference.
Take a reference when assigning the node and release it from the
SCMI device release path. With the device owning that reference,
remove the separate channel-side get/put pair from the core driver.
Fixes: 96da4a99ce50 ("firmware: arm_scmi: Set fwnode for the scmi_device")
Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
---
drivers/firmware/arm_scmi/bus.c | 3 ++-
drivers/firmware/arm_scmi/driver.c | 4 ----
2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c
index dcaefc1aa892..a14df82a9310 100644
--- a/drivers/firmware/arm_scmi/bus.c
+++ b/drivers/firmware/arm_scmi/bus.c
@@ -401,6 +401,7 @@ static void scmi_device_release(struct device *dev)
struct scmi_device *scmi_dev = to_scmi_dev(dev);
scmi_device_release_syspower(scmi_dev);
+ of_node_put(dev->of_node);
kfree_const(scmi_dev->name);
kfree(scmi_dev);
}
@@ -464,7 +465,7 @@ __scmi_device_create(struct device_node *np, struct device *parent,
scmi_dev->id = id;
scmi_dev->dev.parent = parent;
- device_set_node(&scmi_dev->dev, of_fwnode_handle(np));
+ device_set_node(&scmi_dev->dev, of_fwnode_handle(of_node_get(np)));
scmi_dev->dev.bus = &scmi_bus_type;
scmi_dev->dev.release = scmi_device_release;
dev_set_name(&scmi_dev->dev, "scmi_dev.%d", id);
diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index 3e0f0fac9626..515ae884bb2c 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -2789,14 +2789,12 @@ static int scmi_chan_setup(struct scmi_info *info, struct device_node *of_node,
devm_kfree(info->dev, cinfo);
return -EINVAL;
}
- of_node_get(of_node);
cinfo->id = prot_id;
cinfo->dev = &tdev->dev;
cinfo->handle = &info->handle;
ret = info->desc->ops->chan_setup(cinfo, info->dev, tx);
if (ret) {
- of_node_put(of_node);
scmi_device_destroy(info->dev, prot_id, name);
devm_kfree(info->dev, cinfo);
return ret;
@@ -2820,7 +2818,6 @@ static int scmi_chan_setup(struct scmi_info *info, struct device_node *of_node,
/* Destroy channel and device only if created by this call. */
if (tdev) {
info->desc->ops->chan_free(prot_id, cinfo, idr);
- of_node_put(of_node);
scmi_device_destroy(info->dev, prot_id, name);
devm_kfree(info->dev, cinfo);
}
@@ -2906,7 +2903,6 @@ static int scmi_chan_destroy(int id, void *p, void *data)
struct scmi_info *info = handle_to_scmi_info(cinfo->handle);
struct scmi_device *sdev = to_scmi_dev(cinfo->dev);
- of_node_put(cinfo->dev->of_node);
scmi_device_destroy(info->dev, cinfo->id, sdev->name);
cinfo->dev = NULL;
}
--
2.43.0
next prev parent reply other threads:[~2026-07-08 9:00 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-08 8:59 [PATCH v4 00/16] firmware: arm_scmi: Fix SCMI core cleanup paths Sudeep Holla
2026-07-08 8:59 ` [PATCH v4 01/16] firmware: arm_scmi: Publish channel state before callbacks Sudeep Holla
2026-07-08 8:59 ` [PATCH v4 02/16] firmware: arm_scmi: Quiesce notifications before teardown Sudeep Holla
2026-07-08 20:55 ` [PATCH v4 02/16][UPDATED] " Sudeep Holla
2026-07-08 8:59 ` [PATCH v4 03/16] firmware: arm_scmi: Clean up channels on setup failure Sudeep Holla
2026-07-08 9:00 ` [PATCH v4 04/16] firmware: arm_scmi: Free transport channel on IDR failure Sudeep Holla
2026-07-08 9:00 ` [PATCH v4 05/16] firmware: arm_scmi: Avoid IDR updates while cleaning channels Sudeep Holla
2026-07-08 9:00 ` [PATCH v4 06/16] firmware: arm_scmi: Reject out of range DT protocol IDs Sudeep Holla
2026-07-08 9:00 ` [PATCH v4 07/16] firmware: arm_scmi: Use channel ID for transport teardown Sudeep Holla
2026-07-08 9:00 ` [PATCH v4 08/16] firmware: arm_scmi: Unregister device notifier before IDR teardown Sudeep Holla
2026-07-08 9:00 ` [PATCH v4 09/16] firmware: arm_scmi: Protect device request lookup with RCU Sudeep Holla
2026-07-08 9:00 ` [PATCH v4 10/16] firmware: arm_scmi: Drop handle on protocol bind failures Sudeep Holla
2026-07-08 9:00 ` [PATCH v4 11/16] firmware: arm_scmi: Clear SystemPower flag on create failure Sudeep Holla
2026-07-08 9:00 ` Sudeep Holla [this message]
2026-07-08 9:00 ` [PATCH v4 13/16] firmware: arm_scmi: Unwind TX receiver mailbox setup failure Sudeep Holla
2026-07-08 9:00 ` [PATCH v4 14/16] firmware: arm_scmi: Unwind P2A " Sudeep Holla
2026-07-08 9:00 ` [PATCH v4 15/16] firmware: arm_scmi: Fix SCMI device destroy lifetimes Sudeep Holla
2026-07-08 9:00 ` [PATCH v4 16/16] firmware: arm_scmi: Fix transport device teardown lookup Sudeep Holla
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=20260708-scmi_core_fixes-v4-12-53142cd60b63@kernel.org \
--to=sudeep.holla@kernel.org \
--cc=arm-scmi@vger.kernel.org \
--cc=cristian.marussi@arm.com \
--cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.