Skip to content

Commit e2d8ea0

Browse files
plbossartvinodkoul
authored andcommitted
soundwire: fix usages of device_get_named_child_node()
The documentation for device_get_named_child_node() mentions this important point: " The caller is responsible for calling fwnode_handle_put() on the returned fwnode pointer. " Add fwnode_handle_put() to avoid leaked references. Signed-off-by: Pierre-Louis Bossart <[email protected]> Signed-off-by: Bard Liao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 1613e60 commit e2d8ea0

File tree

3 files changed

+32
-7
lines changed

3 files changed

+32
-7
lines changed

drivers/soundwire/amd_manager.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,9 @@ static int sdw_master_read_amd_prop(struct sdw_bus *bus)
571571
amd_manager->wake_en_mask = wake_en_mask;
572572
fwnode_property_read_u32(link, "amd-sdw-power-mode", &power_mode_mask);
573573
amd_manager->power_mode_mask = power_mode_mask;
574+
575+
fwnode_handle_put(link);
576+
574577
return 0;
575578
}
576579

drivers/soundwire/intel_auxdevice.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,10 @@ static int sdw_master_read_intel_prop(struct sdw_bus *bus)
155155
SDW_MASTER_QUIRKS_CLEAR_INITIAL_PARITY;
156156

157157
intel_prop = devm_kzalloc(bus->dev, sizeof(*intel_prop), GFP_KERNEL);
158-
if (!intel_prop)
158+
if (!intel_prop) {
159+
fwnode_handle_put(link);
159160
return -ENOMEM;
161+
}
160162

161163
/* initialize with hardware defaults, in case the properties are not found */
162164
intel_prop->doaise = 0x1;
@@ -184,6 +186,8 @@ static int sdw_master_read_intel_prop(struct sdw_bus *bus)
184186
intel_prop->dodse,
185187
intel_prop->dods);
186188

189+
fwnode_handle_put(link);
190+
187191
return 0;
188192
}
189193

drivers/soundwire/mipi_disco.c

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ int sdw_master_read_prop(struct sdw_bus *bus)
6666
prop->clk_freq = devm_kcalloc(bus->dev, prop->num_clk_freq,
6767
sizeof(*prop->clk_freq),
6868
GFP_KERNEL);
69-
if (!prop->clk_freq)
69+
if (!prop->clk_freq) {
70+
fwnode_handle_put(link);
7071
return -ENOMEM;
72+
}
7173

7274
fwnode_property_read_u32_array(link,
7375
"mipi-sdw-clock-frequencies-supported",
@@ -92,8 +94,10 @@ int sdw_master_read_prop(struct sdw_bus *bus)
9294
prop->clk_gears = devm_kcalloc(bus->dev, prop->num_clk_gears,
9395
sizeof(*prop->clk_gears),
9496
GFP_KERNEL);
95-
if (!prop->clk_gears)
97+
if (!prop->clk_gears) {
98+
fwnode_handle_put(link);
9699
return -ENOMEM;
100+
}
97101

98102
fwnode_property_read_u32_array(link,
99103
"mipi-sdw-supported-clock-gears",
@@ -116,6 +120,8 @@ int sdw_master_read_prop(struct sdw_bus *bus)
116120
fwnode_property_read_u32(link, "mipi-sdw-command-error-threshold",
117121
&prop->err_threshold);
118122

123+
fwnode_handle_put(link);
124+
119125
return 0;
120126
}
121127
EXPORT_SYMBOL(sdw_master_read_prop);
@@ -197,8 +203,10 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
197203
dpn[i].num_words,
198204
sizeof(*dpn[i].words),
199205
GFP_KERNEL);
200-
if (!dpn[i].words)
206+
if (!dpn[i].words) {
207+
fwnode_handle_put(node);
201208
return -ENOMEM;
209+
}
202210

203211
fwnode_property_read_u32_array(node,
204212
"mipi-sdw-port-wordlength-configs",
@@ -236,8 +244,10 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
236244
dpn[i].num_channels,
237245
sizeof(*dpn[i].channels),
238246
GFP_KERNEL);
239-
if (!dpn[i].channels)
247+
if (!dpn[i].channels) {
248+
fwnode_handle_put(node);
240249
return -ENOMEM;
250+
}
241251

242252
fwnode_property_read_u32_array(node,
243253
"mipi-sdw-channel-number-list",
@@ -251,8 +261,10 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
251261
dpn[i].num_ch_combinations,
252262
sizeof(*dpn[i].ch_combinations),
253263
GFP_KERNEL);
254-
if (!dpn[i].ch_combinations)
264+
if (!dpn[i].ch_combinations) {
265+
fwnode_handle_put(node);
255266
return -ENOMEM;
267+
}
256268

257269
fwnode_property_read_u32_array(node,
258270
"mipi-sdw-channel-combination-list",
@@ -274,6 +286,8 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
274286

275287
/* TODO: Read audio mode */
276288

289+
fwnode_handle_put(node);
290+
277291
i++;
278292
}
279293

@@ -348,10 +362,14 @@ int sdw_slave_read_prop(struct sdw_slave *slave)
348362
prop->dp0_prop = devm_kzalloc(&slave->dev,
349363
sizeof(*prop->dp0_prop),
350364
GFP_KERNEL);
351-
if (!prop->dp0_prop)
365+
if (!prop->dp0_prop) {
366+
fwnode_handle_put(port);
352367
return -ENOMEM;
368+
}
353369

354370
sdw_slave_read_dp0(slave, port, prop->dp0_prop);
371+
372+
fwnode_handle_put(port);
355373
}
356374

357375
/*

0 commit comments

Comments
 (0)