From: Dan Carpenter Date: Wed, 31 Jul 2013 08:52:44 +0000 (+0300) Subject: ASoC: dapm: using freed pointer in dapm_kcontrol_add_widget() X-Git-Tag: firefly_0821_release~176^2~4889^2~168^2~2^2~12 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=46a02c978fbc79de856d0fe7a8c1d4fc620796e0;p=firefly-linux-kernel-4.4.55.git ASoC: dapm: using freed pointer in dapm_kcontrol_add_widget() There is a typo here so we end up using the old freed pointer instead of the newly allocated one. (If the "n" is zero then the code works, obviously). Signed-off-by: Dan Carpenter Acked-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 9abb3b21f1fd..d74c3560d556 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -225,13 +225,13 @@ static int dapm_kcontrol_add_widget(struct snd_kcontrol *kcontrol, new_data = krealloc(data, sizeof(*data) + sizeof(widget) * n, GFP_KERNEL); - if (!data) + if (!new_data) return -ENOMEM; - data->wlist.widgets[n - 1] = widget; - data->wlist.num_widgets = n; + new_data->wlist.widgets[n - 1] = widget; + new_data->wlist.num_widgets = n; - kcontrol->private_data = data; + kcontrol->private_data = new_data; return 0; }