diff options
author | Takashi Iwai <tiwai@suse.de> | 2018-03-13 06:18:57 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2018-03-13 10:37:56 -0400 |
commit | 5730f9f744cfe20b771adc33f3b476b95d3eebba (patch) | |
tree | 4993d43ca26c4cd6fbd1199b215d94c9ab09a6cb | |
parent | 491f833134ac474434e1c950925c58b2ac13ca72 (diff) |
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>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | sound/core/pcm_native.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 77ba50ddcf9e..756a9a3884a5 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c | |||
@@ -323,7 +323,7 @@ static int constrain_params_by_rules(struct snd_pcm_substream *substream, | |||
323 | struct snd_pcm_hw_constraints *constrs = | 323 | struct snd_pcm_hw_constraints *constrs = |
324 | &substream->runtime->hw_constraints; | 324 | &substream->runtime->hw_constraints; |
325 | unsigned int k; | 325 | unsigned int k; |
326 | unsigned int rstamps[constrs->rules_num]; | 326 | unsigned int *rstamps; |
327 | unsigned int vstamps[SNDRV_PCM_HW_PARAM_LAST_INTERVAL + 1]; | 327 | unsigned int vstamps[SNDRV_PCM_HW_PARAM_LAST_INTERVAL + 1]; |
328 | unsigned int stamp; | 328 | unsigned int stamp; |
329 | struct snd_pcm_hw_rule *r; | 329 | struct snd_pcm_hw_rule *r; |
@@ -331,7 +331,7 @@ static int constrain_params_by_rules(struct snd_pcm_substream *substream, | |||
331 | struct snd_mask old_mask; | 331 | struct snd_mask old_mask; |
332 | struct snd_interval old_interval; | 332 | struct snd_interval old_interval; |
333 | bool again; | 333 | bool again; |
334 | int changed; | 334 | int changed, err = 0; |
335 | 335 | ||
336 | /* | 336 | /* |
337 | * Each application of rule has own sequence number. | 337 | * Each application of rule has own sequence number. |
@@ -339,8 +339,9 @@ static int constrain_params_by_rules(struct snd_pcm_substream *substream, | |||
339 | * Each member of 'rstamps' array represents the sequence number of | 339 | * Each member of 'rstamps' array represents the sequence number of |
340 | * recent application of corresponding rule. | 340 | * recent application of corresponding rule. |
341 | */ | 341 | */ |
342 | for (k = 0; k < constrs->rules_num; k++) | 342 | rstamps = kcalloc(constrs->rules_num, sizeof(unsigned int), GFP_KERNEL); |
343 | rstamps[k] = 0; | 343 | if (!rstamps) |
344 | return -ENOMEM; | ||
344 | 345 | ||
345 | /* | 346 | /* |
346 | * Each member of 'vstamps' array represents the sequence number of | 347 | * Each member of 'vstamps' array represents the sequence number of |
@@ -398,8 +399,10 @@ retry: | |||
398 | } | 399 | } |
399 | 400 | ||
400 | changed = r->func(params, r); | 401 | changed = r->func(params, r); |
401 | if (changed < 0) | 402 | if (changed < 0) { |
402 | return changed; | 403 | err = changed; |
404 | goto out; | ||
405 | } | ||
403 | 406 | ||
404 | /* | 407 | /* |
405 | * When the parameter is changed, notify it to the caller | 408 | * When the parameter is changed, notify it to the caller |
@@ -430,7 +433,9 @@ retry: | |||
430 | if (again) | 433 | if (again) |
431 | goto retry; | 434 | goto retry; |
432 | 435 | ||
433 | return 0; | 436 | out: |
437 | kfree(rstamps); | ||
438 | return err; | ||
434 | } | 439 | } |
435 | 440 | ||
436 | static int fixup_unreferenced_params(struct snd_pcm_substream *substream, | 441 | static int fixup_unreferenced_params(struct snd_pcm_substream *substream, |