From 17f729b2ed5f25a93e517afe54b348e3bc0c9153 Mon Sep 17 00:00:00 2001 From: Satish Kumar Kodishala Date: Thu, 28 Apr 2022 23:23:45 +0530 Subject: [PATCH] BTFMSLIM: Free memory during error while port open Free memory only during error while opening a port. In success case, memory will be freed during port closure. CRs-Fixed: 3162291, 3113018 Change-Id: Ice2172c7865e5df5898b3ac927f842db1516fd96 --- slimbus/btfm_slim.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/slimbus/btfm_slim.c b/slimbus/btfm_slim.c index b0d8d825b8..ea36de1f83 100644 --- a/slimbus/btfm_slim.c +++ b/slimbus/btfm_slim.c @@ -180,9 +180,13 @@ int btfm_slim_enable_ch(struct btfmslim *btfmslim, struct btfmslim_ch *ch, if (ret == 0) btfm_num_ports_open++; -error: BTFMSLIM_INFO("btfm_num_ports_open: %d", btfm_num_ports_open); + return ret; +error: + BTFMSLIM_INFO("error %d while opening port, btfm_num_ports_open: %d", + ret, btfm_num_ports_open); kfree(chan->dai.sconfig.chs); + chan->dai.sconfig.chs = NULL; return ret; } @@ -221,10 +225,14 @@ int btfm_slim_disable_ch(struct btfmslim *btfmslim, struct btfmslim_ch *ch, } } ch->dai.sconfig.port_mask = 0; - kfree(ch->dai.sconfig.chs); + if (ch->dai.sconfig.chs != NULL) + kfree(ch->dai.sconfig.chs); if (btfm_num_ports_open > 0) btfm_num_ports_open--; + + ch->dai.sruntime = NULL; + BTFMSLIM_INFO("btfm_num_ports_open: %d", btfm_num_ports_open); return ret; }