Re: sound/soc/intel/skylake/skl-topology.c:3642:1: warning: the frame size of 1256 bytes is larger than 1024 bytes

From: Pierre-Louis Bossart
Date: Wed Nov 04 2020 - 12:10:29 EST



sound/soc/intel/skylake/skl-topology.c: In function 'skl_tplg_complete':
sound/soc/intel/skylake/skl-topology.c:3642:1: warning: the frame size of 1256 bytes is larger than 1024 bytes [-Wframe-larger-than=]
3642 | }
| ^

vim +3642 sound/soc/intel/skylake/skl-topology.c

3612
3613 static void skl_tplg_complete(struct snd_soc_component *component)
3614 {
3615 struct snd_soc_dobj *dobj;
3616 struct snd_soc_acpi_mach *mach =
3617 dev_get_platdata(component->card->dev);
3618 int i;
3619
3620 list_for_each_entry(dobj, &component->dobj_list, list) {
3621 struct snd_kcontrol *kcontrol = dobj->control.kcontrol;
3622 struct soc_enum *se =
3623 (struct soc_enum *)kcontrol->private_value;
3624 char **texts = dobj->control.dtexts;
3625 char chan_text[4];
3626
3627 if (dobj->type != SND_SOC_DOBJ_ENUM ||
3628 dobj->control.kcontrol->put !=
3629 skl_tplg_multi_config_set_dmic)
3630 continue;
3631 sprintf(chan_text, "c%d", mach->mach_params.dmic_num);
3632
3633 for (i = 0; i < se->items; i++) {
3634 struct snd_ctl_elem_value val;

that structure seems to be the root-cause of this warning. This can take 512+128 bytes and probably does not belong on the stack.

struct snd_ctl_elem_value {
struct snd_ctl_elem_id id; /* W: element ID */
unsigned int indirect: 1; /* W: indirect access - obsoleted */
union {
union {
long value[128];
long *value_ptr; /* obsoleted */
} integer;
union {
long long value[64];
long long *value_ptr; /* obsoleted */
} integer64;
union {
unsigned int item[128];
unsigned int *item_ptr; /* obsoleted */
} enumerated;
union {
unsigned char data[512];
unsigned char *data_ptr; /* obsoleted */
} bytes;
struct snd_aes_iec958 iec958;
} value; /* RO */
unsigned char reserved[128];
};

3635
3636 if (strstr(texts[i], chan_text)) {
3637 val.value.enumerated.item[0] = i;
3638 kcontrol->put(kcontrol, &val);
3639 }
3640 }
3641 }
3642 }