diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index d2faec9a323e..51516c93916e 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -717,7 +717,7 @@ struct snd_soc_dapm_context { /* A list of widgets associated with an object, typically a snd_kcontrol */ struct snd_soc_dapm_widget_list { int num_widgets; - struct snd_soc_dapm_widget *widgets[]; + struct snd_soc_dapm_widget *widgets[] __counted_by(num_widgets); }; #define for_each_dapm_widgets(list, i, widget) \ diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 2512aadf95f7..2e3df47c9cf3 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -497,8 +497,8 @@ static int dapm_kcontrol_add_widget(struct snd_kcontrol *kcontrol, if (!new_wlist) return -ENOMEM; - new_wlist->widgets[n - 1] = widget; new_wlist->num_widgets = n; + new_wlist->widgets[n - 1] = widget; data->wlist = new_wlist;