[PATCH] soundwire: mipi_disco: Put fwnode on property array read errors
From: Xiangwu Lai
Date: Wed Nov 11 2026 - 21:26:37 EST
sdw_master_read_prop() and sdw_slave_read_dpn() take a fwnode
reference with device_get_named_child_node() and already release it
on the -ENOMEM and success paths. However, the error paths added for
the property array reads jump straight out without dropping the
reference, leaking it on every failed read.
Release the reference on those error paths as well, matching the
existing -ENOMEM handling in the same functions.
Fixes: a489afc105ed ("soundwire: mipi_disco: add error handling for property array read")
Signed-off-by: Xiangwu Lai <laixiangwu@xxxxxxxxxxxxxxxxxxxx>
---
drivers/soundwire/mipi_disco.c | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/drivers/soundwire/mipi_disco.c b/drivers/soundwire/mipi_disco.c
index 259ad98b5..65f8a41e6 100644
--- a/drivers/soundwire/mipi_disco.c
+++ b/drivers/soundwire/mipi_disco.c
@@ -96,8 +96,10 @@ int sdw_master_read_prop(struct sdw_bus *bus)
ret = fwnode_property_read_u32_array(link,
"mipi-sdw-clock-frequencies-supported",
prop->clk_freq, prop->num_clk_freq);
- if (ret < 0)
+ if (ret < 0) {
+ fwnode_handle_put(link);
return ret;
+ }
}
/*
@@ -132,8 +134,10 @@ int sdw_master_read_prop(struct sdw_bus *bus)
scales_prop,
prop->clk_gears,
prop->num_clk_gears);
- if (ret < 0)
+ if (ret < 0) {
+ fwnode_handle_put(link);
return ret;
+ }
}
fwnode_property_read_u32(link, "mipi-sdw-default-frame-rate",
@@ -262,8 +266,10 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
ret = fwnode_property_read_u32_array(node,
"mipi-sdw-port-wordlength-configs",
dpn[i].words, dpn[i].num_words);
- if (ret < 0)
+ if (ret < 0) {
+ fwnode_handle_put(node);
return ret;
+ }
}
fwnode_property_read_u32(node, "mipi-sdw-data-port-type",
@@ -305,8 +311,10 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
ret = fwnode_property_read_u32_array(node,
"mipi-sdw-channel-number-list",
dpn[i].channels, dpn[i].num_channels);
- if (ret < 0)
+ if (ret < 0) {
+ fwnode_handle_put(node);
return ret;
+ }
}
nval = fwnode_property_count_u32(node, "mipi-sdw-channel-combination-list");
@@ -325,8 +333,10 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
"mipi-sdw-channel-combination-list",
dpn[i].ch_combinations,
dpn[i].num_ch_combinations);
- if (ret < 0)
+ if (ret < 0) {
+ fwnode_handle_put(node);
return ret;
+ }
}
fwnode_property_read_u32(node,
@@ -347,14 +357,18 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
dpn[i].lane_list = devm_kcalloc(&slave->dev,
dpn[i].num_lanes, sizeof(*dpn[i].lane_list),
GFP_KERNEL);
- if (!dpn[i].lane_list)
+ if (!dpn[i].lane_list) {
+ fwnode_handle_put(node);
return -ENOMEM;
+ }
ret = fwnode_property_read_u32_array(node,
"mipi-sdw-lane-list",
dpn[i].lane_list, dpn[i].num_lanes);
- if (ret < 0)
+ if (ret < 0) {
+ fwnode_handle_put(node);
return ret;
+ }
}
fwnode_handle_put(node);
--
2.50.1.windows.1