summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWalter Yang <yandongy@codeaurora.org>2016-07-27 15:07:53 +0800
committerWalter Yang <yandongy@codeaurora.org>2016-08-01 10:41:48 +0800
commitfebf4856e5904d19a8cfa008caf720fb1d61041d (patch)
tree92defff183d71aa07b67afb2d5f67d9a6b0fadec
parent956d9b1ab3db6c7fef95964f7f6be8860433b74e (diff)
ASoC: msm: set pointers to NULL after kfree
In lsm-related driver files, some pointers are not set as NULL after the memory is freed, which will leave many dangling pointers. Set them to NULL explicitly to avoid potential risk. CRs-Fixed: 997059 Change-Id: I44925240705608510266a51225cc02611637c571 Signed-off-by: Walter Yang <yandongy@codeaurora.org>
-rw-r--r--sound/soc/msm/msm-cpe-lsm.c9
-rw-r--r--sound/soc/msm/qdsp6v2/msm-dai-slim.c4
-rw-r--r--sound/soc/msm/qdsp6v2/q6lsm.c3
3 files changed, 13 insertions, 3 deletions
diff --git a/sound/soc/msm/msm-cpe-lsm.c b/sound/soc/msm/msm-cpe-lsm.c
index a509107ea9f2..9ea2ece8115b 100644
--- a/sound/soc/msm/msm-cpe-lsm.c
+++ b/sound/soc/msm/msm-cpe-lsm.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2015, Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2016, Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -1209,6 +1209,7 @@ static int msm_cpe_lsm_ioctl_shared(struct snd_pcm_substream *substream,
dev_err(rtd->dev, "%s: No memory for sound model\n",
__func__);
kfree(session->conf_levels);
+ session->conf_levels = NULL;
return -ENOMEM;
}
session->snd_model_size = snd_model.data_size;
@@ -1220,6 +1221,8 @@ static int msm_cpe_lsm_ioctl_shared(struct snd_pcm_substream *substream,
__func__);
kfree(session->conf_levels);
kfree(session->snd_model_data);
+ session->conf_levels = NULL;
+ session->snd_model_data = NULL;
return -EFAULT;
}
@@ -1231,6 +1234,8 @@ static int msm_cpe_lsm_ioctl_shared(struct snd_pcm_substream *substream,
__func__, rc);
kfree(session->snd_model_data);
kfree(session->conf_levels);
+ session->snd_model_data = NULL;
+ session->conf_levels = NULL;
return rc;
}
@@ -1244,6 +1249,8 @@ static int msm_cpe_lsm_ioctl_shared(struct snd_pcm_substream *substream,
lsm_ops->lsm_shmem_dealloc(cpe->core_handle, session);
kfree(session->snd_model_data);
kfree(session->conf_levels);
+ session->snd_model_data = NULL;
+ session->conf_levels = NULL;
return rc;
}
diff --git a/sound/soc/msm/qdsp6v2/msm-dai-slim.c b/sound/soc/msm/qdsp6v2/msm-dai-slim.c
index 2d8177c9712d..7c56f4ad8884 100644
--- a/sound/soc/msm/qdsp6v2/msm-dai-slim.c
+++ b/sound/soc/msm/qdsp6v2/msm-dai-slim.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -467,7 +467,9 @@ static void msm_dai_slim_remove_dai_data(
dai_data_t = &drv_data->slim_dai_data[i];
kfree(dai_data_t->chan_h);
+ dai_data_t->chan_h = NULL;
kfree(dai_data_t->sh_ch);
+ dai_data_t->sh_ch = NULL;
}
}
diff --git a/sound/soc/msm/qdsp6v2/q6lsm.c b/sound/soc/msm/qdsp6v2/q6lsm.c
index d0250535c69b..2bf0c490e834 100644
--- a/sound/soc/msm/qdsp6v2/q6lsm.c
+++ b/sound/soc/msm/qdsp6v2/q6lsm.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2015, Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2016, Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -348,6 +348,7 @@ void q6lsm_client_free(struct lsm_client *client)
q6lsm_mmap_apr_dereg();
mutex_destroy(&client->cmd_lock);
kfree(client);
+ client = NULL;
}
/*