mirror of
https://github.com/torvalds/linux.git
synced 2026-09-26 01:52:03 +02:00
firmware: arm_scmi: Fix OF node reference handling
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: 96da4a99ce ("firmware: arm_scmi: Set fwnode for the scmi_device")
Link: https://patch.msgid.link/20260714-scmi_core_fixes-v6-12-3afe499d46e3@kernel.org
Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
This commit is contained in:
parent
e4c16ae24c
commit
659705f5eb
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user