[PATCH] most: fix a memleak in audio_probe_channel

From: Zhipeng Lu
Date: Mon Jan 22 2024 - 13:22:37 EST


When get_channel fails, audio_probe_channel should free adpt like all
its following error-handling paths after get_channel. Otherwise there
could be a memleak.

Fixes: 15600aea2754 ("staging: most: sound: create one sound card w/ multiple PCM devices per MOST device")
Signed-off-by: Zhipeng Lu <alexious@xxxxxxxxxx>
---
drivers/most/most_snd.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/most/most_snd.c b/drivers/most/most_snd.c
index 45d762804c5e..6cccc9c26796 100644
--- a/drivers/most/most_snd.c
+++ b/drivers/most/most_snd.c
@@ -564,7 +564,8 @@ static int audio_probe_channel(struct most_interface *iface, int channel_id,
if (get_channel(iface, channel_id)) {
pr_err("channel (%s:%d) is already linked\n",
iface->description, channel_id);
- return -EEXIST;
+ ret = -EEXIST;
+ goto err_free_adpt;
}

if (cfg->direction == MOST_CH_TX) {
--
2.34.1