summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTracy Yi2019-08-13 23:10:51 -0500
committerTracy Yi2019-08-13 23:14:40 -0500
commit456cdaaaff2ca2dd6f4c15ae3f784d44d9dc824c (patch)
treed052a9fd5a4d3b635064ec759b1b7800b204a850
parent6f49f1b753e7fee19ded11247c7ff6208d40e905 (diff)
downloadtas2562-stereo-android-driver-456cdaaaff2ca2dd6f4c15ae3f784d44d9dc824c.tar.gz
tas2562-stereo-android-driver-456cdaaaff2ca2dd6f4c15ae3f784d44d9dc824c.tar.xz
tas2562-stereo-android-driver-456cdaaaff2ca2dd6f4c15ae3f784d44d9dc824c.zip
Fixed dereference before null check.
Signed-off-by: Tracy Yi <tracy-yi@ti.com>
-rw-r--r--tas2562-codec.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/tas2562-codec.c b/tas2562-codec.c
index 0ba978a..565c458 100644
--- a/tas2562-codec.c
+++ b/tas2562-codec.c
@@ -128,7 +128,7 @@ static int tas2562iv_put(struct snd_kcontrol *kcontrol,
128 struct snd_ctl_elem_value *ucontrol) 128 struct snd_ctl_elem_value *ucontrol)
129{ 129{
130 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); 130 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
131 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); 131 struct tas2562_priv *p_tas2562 = NULL;
132 int iv_enable = 0, n_result = 0; 132 int iv_enable = 0, n_result = 0;
133 133
134 if (codec == NULL) { 134 if (codec == NULL) {
@@ -136,6 +136,12 @@ static int tas2562iv_put(struct snd_kcontrol *kcontrol,
136 return 0; 136 return 0;
137 } 137 }
138 138
139 p_tas2562 = snd_soc_codec_get_drvdata(codec);
140 if (p_tas2562 == NULL) {
141 pr_err("%s:p_tas2562 is NULL\n", __func__);
142 return 0;
143 }
144
139 iv_enable = ucontrol->value.integer.value[0]; 145 iv_enable = ucontrol->value.integer.value[0];
140 146
141 n_result = tas2562_iv_enable(p_tas2562, iv_enable); 147 n_result = tas2562_iv_enable(p_tas2562, iv_enable);
@@ -149,9 +155,20 @@ static int tas2562iv_get(struct snd_kcontrol *kcontrol,
149 struct snd_ctl_elem_value *ucontrol) 155 struct snd_ctl_elem_value *ucontrol)
150{ 156{
151 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); 157 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
152 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); 158 struct tas2562_priv *p_tas2562 = NULL;
153 int ret, value; 159 int ret, value;
154 160
161 if (codec == NULL) {
162 pr_err("%s:codec is NULL\n", __func__);
163 return 0;
164 }
165
166 p_tas2562 = snd_soc_codec_get_drvdata(codec);
167 if (p_tas2562 == NULL) {
168 pr_err("%s:p_tas2562 is NULL\n", __func__);
169 return 0;
170 }
171
155 ret = p_tas2562->read(p_tas2562, channel_left, 172 ret = p_tas2562->read(p_tas2562, channel_left,
156 TAS2562_POWERCONTROL, &value); 173 TAS2562_POWERCONTROL, &value);
157 if (ret < 0) 174 if (ret < 0)