ALSA: pcm: Remove VLA usage

A helper function used by snd_pcm_hw_refine() still keeps using VLA
for timestamps of hw constraint rules that are non-fixed size.

Let's replace the VLA with a simple kmalloc() array.

Reference: https://lkml.org/lkml/2018/3/7/621
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Change-Id: I487f57fd249099114cdd931bab8034a35a166eec
Signed-off-by: Takashi Iwai <tiwai@suse.de>
(cherry picked from commit 23c2da51e271189c1aaf4a19418b510c20486489)
Signed-off-by: Panchajanya1999 <rsk52959@gmail.com>
This commit is contained in:
Takashi Iwai
2018-03-13 11:18:57 +01:00
committed by Haky86
parent 9cec53619e
commit a86b10f91e

View File

@@ -325,7 +325,7 @@ static int constrain_params_by_rules(struct snd_pcm_substream *substream,
struct snd_pcm_hw_constraints *constrs =
&substream->runtime->hw_constraints;
unsigned int k;
unsigned int rstamps[constrs->rules_num];
unsigned int *rstamps;
unsigned int vstamps[SNDRV_PCM_HW_PARAM_LAST_INTERVAL + 1];
unsigned int stamp;
struct snd_pcm_hw_rule *r;
@@ -333,7 +333,7 @@ static int constrain_params_by_rules(struct snd_pcm_substream *substream,
struct snd_mask old_mask;
struct snd_interval old_interval;
bool again;
int changed;
int changed, err = 0;
/*
* Each application of rule has own sequence number.
@@ -341,8 +341,9 @@ static int constrain_params_by_rules(struct snd_pcm_substream *substream,
* Each member of 'rstamps' array represents the sequence number of
* recent application of corresponding rule.
*/
for (k = 0; k < constrs->rules_num; k++)
rstamps[k] = 0;
rstamps = kcalloc(constrs->rules_num, sizeof(unsigned int), GFP_KERNEL);
if (!rstamps)
return -ENOMEM;
/*
* Each member of 'vstamps' array represents the sequence number of
@@ -400,8 +401,10 @@ retry:
}
changed = r->func(params, r);
if (changed < 0)
return changed;
if (changed < 0) {
err = changed;
goto out;
}
/*
* When the parameter is changed, notify it to the caller
@@ -432,7 +435,9 @@ retry:
if (again)
goto retry;
return 0;
out:
kfree(rstamps);
return err;
}
static int fixup_unreferenced_params(struct snd_pcm_substream *substream,