Commit 09f448a415ece49ceb9d8f21f717aa3c0dbce851
Committed by
Mark Brown
1 parent
8a5b0177a7
ASoC: compress: Fix memory leak from snd_soc_new_compress
Change kzalloc to devm_kzalloc, so compr gets automatically freed when it's no longer needed. Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Showing 1 changed file with 6 additions and 11 deletions Side-by-side Diff
sound/soc/soc-compress.c
... | ... | @@ -896,16 +896,14 @@ |
896 | 896 | else |
897 | 897 | direction = SND_COMPRESS_CAPTURE; |
898 | 898 | |
899 | - compr = kzalloc(sizeof(*compr), GFP_KERNEL); | |
899 | + compr = devm_kzalloc(rtd->card->dev, sizeof(*compr), GFP_KERNEL); | |
900 | 900 | if (!compr) |
901 | 901 | return -ENOMEM; |
902 | 902 | |
903 | 903 | compr->ops = devm_kzalloc(rtd->card->dev, sizeof(soc_compr_ops), |
904 | 904 | GFP_KERNEL); |
905 | - if (!compr->ops) { | |
906 | - ret = -ENOMEM; | |
907 | - goto compr_err; | |
908 | - } | |
905 | + if (!compr->ops) | |
906 | + return -ENOMEM; | |
909 | 907 | |
910 | 908 | if (rtd->dai_link->dynamic) { |
911 | 909 | snprintf(new_name, sizeof(new_name), "(%s)", |
... | ... | @@ -918,7 +916,7 @@ |
918 | 916 | dev_err(rtd->card->dev, |
919 | 917 | "Compress ASoC: can't create compressed for %s: %d\n", |
920 | 918 | rtd->dai_link->name, ret); |
921 | - goto compr_err; | |
919 | + return ret; | |
922 | 920 | } |
923 | 921 | |
924 | 922 | rtd->pcm = be_pcm; |
... | ... | @@ -954,7 +952,7 @@ |
954 | 952 | dev_err(component->dev, |
955 | 953 | "Compress ASoC: can't create compress for codec %s: %d\n", |
956 | 954 | component->name, ret); |
957 | - goto compr_err; | |
955 | + return ret; | |
958 | 956 | } |
959 | 957 | |
960 | 958 | /* DAPM dai link stream work */ |
961 | 959 | |
... | ... | @@ -965,11 +963,8 @@ |
965 | 963 | |
966 | 964 | dev_info(rtd->card->dev, "Compress ASoC: %s <-> %s mapping ok\n", |
967 | 965 | codec_dai->name, cpu_dai->name); |
968 | - return ret; | |
969 | 966 | |
970 | -compr_err: | |
971 | - kfree(compr); | |
972 | - return ret; | |
967 | + return 0; | |
973 | 968 | } |
974 | 969 | EXPORT_SYMBOL_GPL(snd_soc_new_compress); |