sound: soc: fix invalid free of devm_ allocated data
PATCH 1/1 sound: soc: fix invalid free of devm_ allocated data
The objects allocated by devm_* APIs are managed by devres and are freed when the device is detached. Hence there is no need to use kfree() explicitly.
--- sound/soc/soc-core.c | 2 -- 1 file changed, 2 deletions(-)
sound/soc/soc-core.c +0 -2
@@ -4197,7 +4197,6 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,dev_err (card->dev,"ASoC: Property '%s' index %d could not be read: %d\n" , propname,2 * i, ret); -kfree (routes);return -EINVAL ; } ret = of_property_read_string_index(np, propname,
@@ -4206,7 +4205,6 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,dev_err (card->dev,"ASoC: Property '%s' index %d could not be read: %d\n" , propname, (2 * i) +1 , ret); -kfree (routes);return -EINVAL ; } }
Signature · 1 line
1.7.9.5
Quoted 2 lines · Silviu-Mihai Popescu
The objects allocated by devm_* APIs are managed by devres and are freed when the device is detached. Hence there is no need to use
kfree()explicitly.
In this case since we're in error handling paths which might not be fatal (though I suspect they probably should be normally) it looks like the better fix is to use devm_kfree() to free immediately. Otherwise the unused memory will end up hanging around for as long as the device is bound.
Quoted 2 lines · Silviu-Mihai Popescu
The objects allocated by devm_* APIs are managed by devres and are freed when the device is detached. Hence there is no need to use
kfree()explicitly.
...but I applied this anyway since it's clearly an improvement and a small leak is better than a crash.