summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMeng Wang <mwang@codeaurora.org>2016-07-27 14:49:10 +0800
committerGerrit - the friendly Code Review server <code-review@localhost>2016-08-10 23:22:14 -0700
commit59ff3301d529ed74f414f15b69365a0c7babb7d5 (patch)
tree82cdb2dfb93897e780c59294340ea26157211d72
parent7b2050ceb62d8d6c64cca04cf88ec8f862a1d343 (diff)
ASoC: msm: set pointer to null after kfree
In machine drivers, 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: 997062 Change-Id: Ifa27a21cb76688101b758a34eddf69b160c27c79 Signed-off-by: Meng Wang <mwang@codeaurora.org>
-rw-r--r--sound/soc/msm/msm-audio-pinctrl.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/sound/soc/msm/msm-audio-pinctrl.c b/sound/soc/msm/msm-audio-pinctrl.c
index d30b0c40f993..2b30271500eb 100644
--- a/sound/soc/msm/msm-audio-pinctrl.c
+++ b/sound/soc/msm/msm-audio-pinctrl.c
@@ -1,4 +1,4 @@
- /* Copyright (c) 2015, The Linux Foundation. All rights reserved.
+ /* Copyright (c) 2015-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
@@ -200,28 +200,40 @@ int msm_gpioset_initialize(enum pinctrl_client client,
err:
/* Free up memory allocated for gpio set combinations */
for (i = 0; i < gpioset_info[client].gpiosets_max; i++) {
- if (NULL != gpioset_info[client].gpiosets[i])
+ if (gpioset_info[client].gpiosets[i] != NULL) {
devm_kfree(dev, gpioset_info[client].gpiosets[i]);
+ gpioset_info[client].gpiosets[i] = NULL;
+ }
}
- if (NULL != gpioset_info[client].gpiosets)
+ if (gpioset_info[client].gpiosets != NULL) {
devm_kfree(dev, gpioset_info[client].gpiosets);
+ gpioset_info[client].gpiosets = NULL;
+ }
/* Free up memory allocated for gpio set combinations */
for (i = 0; i < gpioset_info[client].gpiosets_comb_max; i++) {
- if (NULL != gpioset_info[client].gpiosets_comb_names[i])
+ if (gpioset_info[client].gpiosets_comb_names[i] != NULL) {
devm_kfree(dev,
gpioset_info[client].gpiosets_comb_names[i]);
+ gpioset_info[client].gpiosets_comb_names[i] = NULL;
+ }
}
- if (NULL != gpioset_info[client].gpiosets_comb_names)
+ if (gpioset_info[client].gpiosets_comb_names != NULL) {
devm_kfree(dev, gpioset_info[client].gpiosets_comb_names);
+ gpioset_info[client].gpiosets_comb_names = NULL;
+ }
/* Free up memory allocated for handles to pinctrl states */
- if (NULL != pinctrl_info[client].cdc_lines)
+ if (pinctrl_info[client].cdc_lines != NULL) {
devm_kfree(dev, pinctrl_info[client].cdc_lines);
+ pinctrl_info[client].cdc_lines = NULL;
+ }
/* Free up memory allocated for counter of gpio sets */
- if (NULL != gpioset_info[client].gpioset_state)
+ if (gpioset_info[client].gpioset_state != NULL) {
devm_kfree(dev, gpioset_info[client].gpioset_state);
+ gpioset_info[client].gpioset_state = NULL;
+ }
success:
return ret;