ASoC: dapm: using freed pointer in dapm_kcontrol_add_widget()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 31 Jul 2013 08:52:44 +0000 (11:52 +0300)
committerMark Brown <broonie@linaro.org>
Wed, 31 Jul 2013 11:19:25 +0000 (12:19 +0100)
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 <dan.carpenter@oracle.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
sound/soc/soc-dapm.c

index 9abb3b21f1fd35a7f59bbbcbb9f10c8112e29f05..d74c3560d556cc45dbb9191ccd74705258c7107d 100644 (file)
@@ -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;
 }