Skip to content

Commit

Permalink
ASoC: topology: kfree kcontrol->private_value before freeing kcontrol
Browse files Browse the repository at this point in the history
kcontrol->private_value is being kfree'd after kcontrol has been freed
(in previous call to snd_ctl_remove).  Instead, fix this by kfreeing
the private_value before kcontrol.

CoverityScan CID#1388311 "Read from pointer after free"

Fixes: eea3dd4 ("ASoC: topology: Only free TLV for volume mixers of a widget")
Signed-off-by: Colin Ian King <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
Colin Ian King authored and broonie committed Dec 15, 2016
1 parent a5de5b7 commit c2b3612
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions sound/soc/soc-topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,13 +514,12 @@ static void remove_widget(struct snd_soc_component *comp,
== SND_SOC_TPLG_TYPE_MIXER)
kfree(kcontrol->tlv.p);

snd_ctl_remove(card, kcontrol);

/* Private value is used as struct soc_mixer_control
* for volume mixers or soc_bytes_ext for bytes
* controls.
*/
kfree((void *)kcontrol->private_value);
snd_ctl_remove(card, kcontrol);
}
kfree(w->kcontrol_news);
}
Expand Down

0 comments on commit c2b3612

Please sign in to comment.