Skip to content

Commit e3b1e6a

Browse files
committed
ASoC: dapm: Remove snd_soc_of_parse_audio_routing() due to deferred probe
This reverts commit f8781db (ASoC: dapm: Augment existing card DAPM routes in snd_soc_of_parse_audio_routing) since it is broken for deferred probing as it ends up storing data allocated with devm_ over multiple instantiations of the device. Reported-by: Russell King <rmk+kernel@arm.linux.org.uk> Tested-by: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 1810afd commit e3b1e6a

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

sound/soc/soc-core.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3231,7 +3231,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
32313231
const char *propname)
32323232
{
32333233
struct device_node *np = card->dev->of_node;
3234-
int num_routes, old_routes;
3234+
int num_routes;
32353235
struct snd_soc_dapm_route *routes;
32363236
int i, ret;
32373237

@@ -3249,29 +3249,25 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
32493249
return -EINVAL;
32503250
}
32513251

3252-
old_routes = card->num_dapm_routes;
3253-
routes = devm_kzalloc(card->dev,
3254-
(old_routes + num_routes) * sizeof(*routes),
3252+
routes = devm_kzalloc(card->dev, num_routes * sizeof(*routes),
32553253
GFP_KERNEL);
32563254
if (!routes) {
32573255
dev_err(card->dev,
32583256
"ASoC: Could not allocate DAPM route table\n");
32593257
return -EINVAL;
32603258
}
32613259

3262-
memcpy(routes, card->dapm_routes, old_routes * sizeof(*routes));
3263-
32643260
for (i = 0; i < num_routes; i++) {
32653261
ret = of_property_read_string_index(np, propname,
3266-
2 * i, &routes[old_routes + i].sink);
3262+
2 * i, &routes[i].sink);
32673263
if (ret) {
32683264
dev_err(card->dev,
32693265
"ASoC: Property '%s' index %d could not be read: %d\n",
32703266
propname, 2 * i, ret);
32713267
return -EINVAL;
32723268
}
32733269
ret = of_property_read_string_index(np, propname,
3274-
(2 * i) + 1, &routes[old_routes + i].source);
3270+
(2 * i) + 1, &routes[i].source);
32753271
if (ret) {
32763272
dev_err(card->dev,
32773273
"ASoC: Property '%s' index %d could not be read: %d\n",
@@ -3280,7 +3276,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
32803276
}
32813277
}
32823278

3283-
card->num_dapm_routes += num_routes;
3279+
card->num_dapm_routes = num_routes;
32843280
card->dapm_routes = routes;
32853281

32863282
return 0;

0 commit comments

Comments
 (0)