clear-pkgs-linux-iot-lts2018/0428-ASoC-tdf8532-fix-memle...

87 lines
3.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Liu Changcheng <changcheng.liu@intel.com>
Date: Fri, 11 May 2018 17:24:01 +0800
Subject: [PATCH] ASoC: tdf8532: fix memleak in tdf8532_wait_state
Fix kmemleak issue in tdf8532_wait_state function by releasing
the memory getting allocated continuosly in instance of get_dev_status_repl
i.e. status_repl before exiting the function.
kernel memory leakage in audio stack/kmemleak backtrace:
unreferenced object 0xffff88006227cc20 (size 32):
comm "irq/25-snd_soc_", pid 2302, jiffies 4294679082 (age 5506.010s)
hex dump (first 32 bytes):
02 00 03 80 80 02 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffff81afb06a>] kmemleak_alloc+0x4a/0xa0
[<ffffffff81201108>] __kmalloc+0x128/0x210
[<ffffffffa01b3426>] tdf8532_wait_state.constprop.5+0x116/0x260 [snd_soc_tdf8532]
[<ffffffffa01b361b>] tdf8532_dai_trigger+0xab/0x15a [snd_soc_tdf8532]
[<ffffffff819181e5>] soc_pcm_trigger+0x75/0x130
[<ffffffff81919339>] dpcm_do_trigger.isra.6+0x29/0x90
[<ffffffff8191952d>] dpcm_be_dai_trigger+0x18d/0x350
Change-Id: I550897d6b1efbd5ebbe15ab47038adf99581a82f
Tracked-On:
Signed-off-by: Liu Changcheng <changcheng.liu@intel.com>
Reviewed-on:
Reviewed-by: Shaik, ShahinaX <shahinax.shaik@intel.com>
Reviewed-by: Singh, Guneshwor O <guneshwor.o.singh@intel.com>
Reviewed-by: Gogineni, GiribabuX <giribabux.gogineni@intel.com>
Reviewed-by: Tewani, Pradeep D <pradeep.d.tewani@intel.com>
Reviewed-by: Kesapragada, Pardha Saradhi <pardha.saradhi.kesapragada@intel.com>
Reviewed-by: Kp, Jeeja <jeeja.kp@intel.com>
Tested-by: Madiwalar, MadiwalappaX <madiwalappax.madiwalar@intel.com>
---
sound/soc/codecs/tdf8532.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/sound/soc/codecs/tdf8532.c b/sound/soc/codecs/tdf8532.c
index a5e2a02..dd4cebe 100644
--- a/sound/soc/codecs/tdf8532.c
+++ b/sound/soc/codecs/tdf8532.c
@@ -174,29 +174,31 @@ static int tdf8532_wait_state(struct tdf8532_priv *dev_data, u8 req_state,
unsigned long timeout_point = jiffies + msecs_to_jiffies(timeout);
int ret;
struct get_dev_status_repl *status_repl = NULL;
+ u8 cur_state = STATE_NONE;
struct device *dev = &(dev_data->i2c->dev);
do {
ret = tdf8532_get_state(dev_data, &status_repl);
if (ret < 0)
goto out;
-
+ cur_state = status_repl->state;
print_hex_dump_debug("tdf8532-codec: wait_state: ",
DUMP_PREFIX_NONE, 32, 1, status_repl,
6, false);
+
+ kfree(status_repl);
+ status_repl = NULL;
} while (time_before(jiffies, timeout_point)
- && status_repl->state != req_state);
+ && cur_state != req_state);
- if (status_repl->state == req_state)
+ if (cur_state == req_state)
return 0;
+out:
ret = -ETIME;
dev_err(dev, "tdf8532-codec: state: %u, req_state: %u, ret: %d\n",
- status_repl->state, req_state, ret);
-
-out:
- kfree(status_repl);
+ cur_state, req_state, ret);
return ret;
}
--
https://clearlinux.org