ASoC: tegra-alt: Set freed memory to NULL
Aniket Bahadarpurkar [Fri, 5 Sep 2014 06:42:05 +0000 (11:42 +0530)]
Set memory freed using kfree to NULL to avoid corruption.
This is observed in case of deferred probe scenario.

Bug 200034236

Change-Id: I9d0771ecc43bf7fdaaa9801822d938a45d637c57
Signed-off-by: Aniket Bahadarpurkar <aniketb@nvidia.com>
Reviewed-on: http://git-master/r/495910
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Arun Shamanna Lakshmi <aruns@nvidia.com>

sound/soc/tegra-alt/tegra_asoc_hwdep_alt.c
sound/soc/tegra-alt/tegra_asoc_machine_alt.c
sound/soc/tegra-alt/tegra_vcm30t124_alt.c

index 8770934..1f8e7d4 100644 (file)
@@ -103,6 +103,7 @@ static int tegra_asoc_hwdep_update_mapping_table(struct snd_soc_card *card,
 
 ERR:
        kfree(map);
+       map = NULL;
        return err;
 }
 
index d872f90..49798e7 100644 (file)
@@ -1655,6 +1655,7 @@ EXPORT_SYMBOL_GPL(tegra_machine_get_dai_link);
 void tegra_machine_remove_dai_link(void)
 {
        kfree(tegra_asoc_machine_links);
+       tegra_asoc_machine_links = NULL;
 }
 EXPORT_SYMBOL_GPL(tegra_machine_remove_dai_link);
 
@@ -1750,6 +1751,7 @@ EXPORT_SYMBOL_GPL(tegra_machine_get_codec_conf);
 void tegra_machine_remove_codec_conf(void)
 {
        kfree(tegra_asoc_codec_conf);
+       tegra_asoc_codec_conf = NULL;
 }
 EXPORT_SYMBOL_GPL(tegra_machine_remove_codec_conf);
 
@@ -2099,6 +2101,10 @@ void tegra_machine_remove_extra_mem_alloc(unsigned int num_codec_links)
                        kfree(tegra_asoc_machine_links[i].name);
                        kfree(tegra_asoc_machine_links[i].params);
                        kfree(tegra_asoc_machine_links[j].name);
+
+                       tegra_asoc_machine_links[i].name = NULL;
+                       tegra_asoc_machine_links[i].params = NULL;
+                       tegra_asoc_machine_links[j].name = NULL;
                }
 }
 EXPORT_SYMBOL_GPL(tegra_machine_remove_extra_mem_alloc);
index 216cdc4..3a3783c 100644 (file)
@@ -954,6 +954,7 @@ static void tegra_vcm30t124_new_codec_links(
 static void tegra_vcm30t124_free_codec_links(void)
 {
        kfree(tegra_vcm30t124_codec_links);
+       tegra_vcm30t124_codec_links = NULL;
 }
 
 static void tegra_vcm30t124_new_codec_conf(
@@ -980,6 +981,7 @@ static void tegra_vcm30t124_new_codec_conf(
 static void tegra_vcm30t124_free_codec_conf(void)
 {
        kfree(tegra_vcm30t124_codec_conf);
+       tegra_vcm30t124_codec_conf = NULL;
 }
 
 static const int tegra_vcm30t124_srate_values[] = {