* [PATCH v2] pcm_native: Remove VLA usage
@ 2018-03-28 22:24 Kyle Spiers
2018-03-28 23:42 ` Takashi Sakamoto
2018-03-29 5:34 ` Takashi Iwai
0 siblings, 2 replies; 5+ messages in thread
From: Kyle Spiers @ 2018-03-28 22:24 UTC (permalink / raw)
To: perex; +Cc: tiwai, o-takashi, alsa-devel, linux-kernel, keescook, Kyle Spiers
As part of the effort to remove VLAs from the kernel[1], this changes
the allocation of the rstamps array from being on the stack to being
kcalloc()ed. This also allows for the removal of the explicit zeroing
loop.
Signed-off-by: Kyle Spiers <kyle@spiers.me>
---
sound/core/pcm_native.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 77ba50d..db5e3c5 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,
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;
@@ -339,8 +339,8 @@ 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(*rstamps), GFP_KERNEL);
/*
* Each member of 'vstamps' array represents the sequence number of
@@ -398,8 +398,10 @@ static int constrain_params_by_rules(struct snd_pcm_substream *substream,
}
changed = r->func(params, r);
- if (changed < 0)
+ if (changed < 0) {
+ kfree(rstamps);
return changed;
+ }
/*
* When the parameter is changed, notify it to the caller
@@ -430,6 +432,7 @@ static int constrain_params_by_rules(struct snd_pcm_substream *substream,
if (again)
goto retry;
+ kfree(rstamps);
return 0;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] pcm_native: Remove VLA usage
2018-03-28 22:24 [PATCH v2] pcm_native: Remove VLA usage Kyle Spiers
@ 2018-03-28 23:42 ` Takashi Sakamoto
2018-03-29 5:34 ` Takashi Iwai
1 sibling, 0 replies; 5+ messages in thread
From: Takashi Sakamoto @ 2018-03-28 23:42 UTC (permalink / raw)
To: Kyle Spiers, perex; +Cc: tiwai, alsa-devel, linux-kernel, keescook
Hi,
On Mar 29 2018 07:24, Kyle Spiers wrote:
> As part of the effort to remove VLAs from the kernel[1], this changes
> the allocation of the rstamps array from being on the stack to being
> kcalloc()ed. This also allows for the removal of the explicit zeroing
> loop.
>
> Signed-off-by: Kyle Spiers <kyle@spiers.me>
> ---
> sound/core/pcm_native.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
This bug was already fixed at a commit 5730f9f744cf ('
ALSA: pcm: Remove VLA usage')[1][2].
[1]
https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git/commit/sound/core/pcm_native.c?h=for-next&id=5730f9f744cfe20b771adc33f3b476b95d3eebba
[2]
http://mailman.alsa-project.org/pipermail/alsa-devel/2018-March/133268.html
Thanks
Takashi Sakamoto
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] pcm_native: Remove VLA usage
@ 2018-03-28 23:42 ` Takashi Sakamoto
0 siblings, 0 replies; 5+ messages in thread
From: Takashi Sakamoto @ 2018-03-28 23:42 UTC (permalink / raw)
To: Kyle Spiers, perex; +Cc: alsa-devel, tiwai, keescook, linux-kernel
Hi,
On Mar 29 2018 07:24, Kyle Spiers wrote:
> As part of the effort to remove VLAs from the kernel[1], this changes
> the allocation of the rstamps array from being on the stack to being
> kcalloc()ed. This also allows for the removal of the explicit zeroing
> loop.
>
> Signed-off-by: Kyle Spiers <kyle@spiers.me>
> ---
> sound/core/pcm_native.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
This bug was already fixed at a commit 5730f9f744cf ('
ALSA: pcm: Remove VLA usage')[1][2].
[1]
https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git/commit/sound/core/pcm_native.c?h=for-next&id=5730f9f744cfe20b771adc33f3b476b95d3eebba
[2]
http://mailman.alsa-project.org/pipermail/alsa-devel/2018-March/133268.html
Thanks
Takashi Sakamoto
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] pcm_native: Remove VLA usage
2018-03-28 22:24 [PATCH v2] pcm_native: Remove VLA usage Kyle Spiers
@ 2018-03-29 5:34 ` Takashi Iwai
2018-03-29 5:34 ` Takashi Iwai
1 sibling, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2018-03-29 5:34 UTC (permalink / raw)
To: Kyle Spiers; +Cc: perex, alsa-devel, keescook, o-takashi, linux-kernel
On Thu, 29 Mar 2018 00:24:00 +0200,
Kyle Spiers wrote:
>
> As part of the effort to remove VLAs from the kernel[1], this changes
> the allocation of the rstamps array from being on the stack to being
> kcalloc()ed. This also allows for the removal of the explicit zeroing
> loop.
>
> Signed-off-by: Kyle Spiers <kyle@spiers.me>
It's been already fixed weeks ago...
thanks,
Takashi
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] pcm_native: Remove VLA usage
@ 2018-03-29 5:34 ` Takashi Iwai
0 siblings, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2018-03-29 5:34 UTC (permalink / raw)
To: Kyle Spiers; +Cc: perex, alsa-devel, keescook, o-takashi, linux-kernel
On Thu, 29 Mar 2018 00:24:00 +0200,
Kyle Spiers wrote:
>
> As part of the effort to remove VLAs from the kernel[1], this changes
> the allocation of the rstamps array from being on the stack to being
> kcalloc()ed. This also allows for the removal of the explicit zeroing
> loop.
>
> Signed-off-by: Kyle Spiers <kyle@spiers.me>
It's been already fixed weeks ago...
thanks,
Takashi
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-03-29 5:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-28 22:24 [PATCH v2] pcm_native: Remove VLA usage Kyle Spiers
2018-03-28 23:42 ` Takashi Sakamoto
2018-03-28 23:42 ` Takashi Sakamoto
2018-03-29 5:34 ` Takashi Iwai
2018-03-29 5:34 ` Takashi Iwai
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.