ASoC: wm_adsp: Limit firmware control name to ALSA control name size
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>
Mon, 13 Apr 2015 12:27:56 +0000 (13:27 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 27 Apr 2015 14:38:24 +0000 (15:38 +0100)
ALSA only supports control names up to 44 bytes, so there is no point
allocating a whole page of memory to hold the control name, just limit
the control name to 44 bytes.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/wm_adsp.c

index 3f6b49dc98c03ff15c035885db8a163ae32846db..c2912033e3e37a28bf3a62055ba8c935f8bf3e1b 100644 (file)
@@ -789,7 +789,7 @@ static int wm_adsp_create_control(struct wm_adsp *dsp,
        char *region_name;
        int ret;
 
-       name = kmalloc(PAGE_SIZE, GFP_KERNEL);
+       name = kmalloc(SNDRV_CTL_ELEM_ID_NAME_MAXLEN, GFP_KERNEL);
        if (!name)
                return -ENOMEM;
 
@@ -814,7 +814,7 @@ static int wm_adsp_create_control(struct wm_adsp *dsp,
                goto err_name;
        }
 
-       snprintf(name, PAGE_SIZE, "DSP%d %s %x",
+       snprintf(name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, "DSP%d %s %x",
                 dsp->num, region_name, alg_region->alg);
 
        list_for_each_entry(ctl, &dsp->ctl_list,