lkml.org 
[lkml]   [2018]   [Aug]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] ASoC: smd845: fix memory leak
In case memory resources for *card* were allocated, release them before
return.

Addresses-Coverity-ID: 1472244 ("Resource leak")
Fixes: 6b1687bf76ef ("ASoC: qcom: add sdm845 sound card support")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
NOTE: Notice that there are many places in which the return values of
functions snd_soc_dai_set_sysclk() and snd_soc_dai_set_fmt() are
not being checked. I wonder if this is intentional. Otherwise, I
can send a patch for that. Please, confirm. Thanks!

sound/soc/qcom/sdm845.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c
index be0cb11..c1adb77 100644
--- a/sound/soc/qcom/sdm845.c
+++ b/sound/soc/qcom/sdm845.c
@@ -222,8 +222,10 @@ static int sdm845_snd_platform_probe(struct platform_device *pdev)

/* Allocate the private data */
data = kzalloc(sizeof(*data), GFP_KERNEL);
- if (!data)
- return -ENOMEM;
+ if (!data) {
+ ret = -ENOMEM;
+ goto data_alloc_fail;
+ }

card->dev = dev;
dev_set_drvdata(dev, card);
@@ -248,6 +250,7 @@ static int sdm845_snd_platform_probe(struct platform_device *pdev)
kfree(card->dai_link);
parse_dt_fail:
kfree(data);
+data_alloc_fail:
kfree(card);
return ret;
}
--
2.7.4
\
 
 \ /
  Last update: 2018-08-03 15:43    [W:0.030 / U:6.952 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site