From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: "Wood, Brian J" Date: Thu, 14 Mar 2019 15:01:49 -0700 Subject: [PATCH] ASoC: Intel: Fix memory leak from early function return This fix takes care of cases where host|link_cpr_cfg->id.pvt_id is < 0. We now flow down into the error label to properly free the dynamically allocated memory. Tracked-On: PKT-1810 Change-Id: I9ce3a6220430d2b3580e889081a651ffed12cc4f Signed-off-by: Wood, Brian J --- sound/soc/intel/skylake/skl-messages.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sound/soc/intel/skylake/skl-messages.c b/sound/soc/intel/skylake/skl-messages.c index af294f6fd23b..9f70a4f7f252 100644 --- a/sound/soc/intel/skylake/skl-messages.c +++ b/sound/soc/intel/skylake/skl-messages.c @@ -540,8 +540,10 @@ static int cnl_sdw_bra_pipe_cfg_pb(struct skl_sst *ctx, link_cpr_cfg->id.instance_id = 2; link_cpr_cfg->id.pvt_id = skl_get_pvt_id(ctx, (uuid_le *)link_cpr_cfg->guid, link_cpr_cfg->id.instance_id); - if (link_cpr_cfg->id.pvt_id < 0) - return -EINVAL; + if (link_cpr_cfg->id.pvt_id < 0) { + ret = -EINVAL; + goto error; + } link_cpr_cfg->dev_type = SKL_DEVICE_SDW_PCM; #if IS_ENABLED(CONFIG_SND_SOC_INTEL_CNL_FPGA) @@ -820,8 +822,10 @@ static int cnl_sdw_bra_pipe_cfg_cp(struct skl_sst *ctx, host_cpr_cfg->id.instance_id = 4; host_cpr_cfg->id.pvt_id = skl_get_pvt_id(ctx, (uuid_le *)host_cpr_cfg->guid, host_cpr_cfg->id.instance_id); - if (host_cpr_cfg->id.pvt_id < 0) - return -EINVAL; + if (host_cpr_cfg->id.pvt_id < 0) { + ret = -EINVAL; + goto error; + } host_cpr_cfg->dev_type = SKL_DEVICE_HDAHOST; host_cpr_cfg->hw_conn_type = SKL_CONN_SINK; -- https://clearlinux.org