Skip to content

Commit 19d61f0

Browse files
Bartosz Golaszewskigregkh
authored andcommitted
platform/x86: intel: chtwc_int33fe: don't dereference swnode args
commit 527250c upstream. Members of struct software_node_ref_args should not be dereferenced directly but set using the provided macros. Commit d7cdbbc ("software node: allow referencing firmware nodes") changed the name of the software node member and caused a build failure. Remove all direct dereferences of the ref struct as a fix. However, this driver also seems to abuse the software node interface by waiting for a node with an arbitrary name "intel-xhci-usb-sw" to appear in the system before setting up the reference for the I2C device, while the actual software node already exists in the intel-xhci-usb-role-switch module and should be used to set up a static reference. Add a FIXME for a future improvement. Fixes: d7cdbbc ("software node: allow referencing firmware nodes") Fixes: 53c24c2 ("platform/x86: intel_cht_int33fe: use inline reference properties") Cc: stable@vger.kernel.org Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Closes: https://lore.kernel.org/all/20251121111534.7cdbfe5c@canb.auug.org.au/ Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Reviewed-by: Hans de Goede <johannes.goede@oss.qualcomm.com> Acked-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 17be376 commit 19d61f0

1 file changed

Lines changed: 20 additions & 9 deletions

File tree

drivers/platform/x86/intel/chtwc_int33fe.c

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static const struct software_node max17047_node = {
7777
* software node.
7878
*/
7979
static struct software_node_ref_args fusb302_mux_refs[] = {
80-
{ .node = NULL },
80+
SOFTWARE_NODE_REFERENCE(NULL),
8181
};
8282

8383
static const struct property_entry fusb302_properties[] = {
@@ -190,19 +190,22 @@ static void cht_int33fe_remove_nodes(struct cht_int33fe_data *data)
190190
{
191191
software_node_unregister_node_group(node_group);
192192

193-
if (fusb302_mux_refs[0].node) {
194-
fwnode_handle_put(software_node_fwnode(fusb302_mux_refs[0].node));
195-
fusb302_mux_refs[0].node = NULL;
196-
}
197-
198193
if (data->dp) {
199194
data->dp->secondary = NULL;
200195
fwnode_handle_put(data->dp);
201196
data->dp = NULL;
202197
}
203198
}
204199

205-
static int cht_int33fe_add_nodes(struct cht_int33fe_data *data)
200+
static void cht_int33fe_put_swnode(void *data)
201+
{
202+
struct fwnode_handle *fwnode = data;
203+
204+
fwnode_handle_put(fwnode);
205+
fusb302_mux_refs[0] = SOFTWARE_NODE_REFERENCE(NULL);
206+
}
207+
208+
static int cht_int33fe_add_nodes(struct device *dev, struct cht_int33fe_data *data)
206209
{
207210
const struct software_node *mux_ref_node;
208211
int ret;
@@ -212,17 +215,25 @@ static int cht_int33fe_add_nodes(struct cht_int33fe_data *data)
212215
* until the mux driver has created software node for the mux device.
213216
* It means we depend on the mux driver. This function will return
214217
* -EPROBE_DEFER until the mux device is registered.
218+
*
219+
* FIXME: the relevant software node exists in intel-xhci-usb-role-switch
220+
* and - if exported - could be used to set up a static reference.
215221
*/
216222
mux_ref_node = software_node_find_by_name(NULL, "intel-xhci-usb-sw");
217223
if (!mux_ref_node)
218224
return -EPROBE_DEFER;
219225

226+
ret = devm_add_action_or_reset(dev, cht_int33fe_put_swnode,
227+
software_node_fwnode(mux_ref_node));
228+
if (ret)
229+
return ret;
230+
220231
/*
221232
* Update node used in "usb-role-switch" property. Note that we
222233
* rely on software_node_register_node_group() to use the original
223234
* instance of properties instead of copying them.
224235
*/
225-
fusb302_mux_refs[0].node = mux_ref_node;
236+
fusb302_mux_refs[0] = SOFTWARE_NODE_REFERENCE(mux_ref_node);
226237

227238
ret = software_node_register_node_group(node_group);
228239
if (ret)
@@ -345,7 +356,7 @@ static int cht_int33fe_typec_probe(struct platform_device *pdev)
345356
return fusb302_irq;
346357
}
347358

348-
ret = cht_int33fe_add_nodes(data);
359+
ret = cht_int33fe_add_nodes(dev, data);
349360
if (ret)
350361
return ret;
351362

0 commit comments

Comments
 (0)