Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1467223 > unrolled thread
| Started by | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| First post | 2016-08-21 21:50 +0200 |
| Last post | 2016-08-22 09:30 +0200 |
| Articles | 14 — 6 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 0/2] ALSA: compress: Fine-tuning for snd_compr_set_params() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-21 21:50 +0200
[PATCH 1/2] ALSA: compress: Use memdup_user() rather than duplicating its implementation SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-21 21:50 +0200
Re: [PATCH 1/2] ALSA: compress: Use memdup_user() rather than duplicating its implementation Vinod Koul <vinod.koul@intel.com> - 2016-08-22 07:00 +0200
Re: [alsa-devel] [PATCH 1/2] ALSA: compress: Use memdup_user() rather than duplicating its implementation Takashi Iwai <tiwai@suse.de> - 2016-08-22 14:10 +0200
Re: [alsa-devel] [PATCH 1/2] ALSA: compress: Use memdup_user() rather than duplicating its implementation Vinod Koul <vinod.koul@intel.com> - 2016-08-23 05:50 +0200
[PATCH 2/2] ALSA: compress: Reduce the scope for two variables in snd_compr_set_params() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-21 21:50 +0200
Re: [PATCH 2/2] ALSA: compress: Reduce the scope for two variables in snd_compr_set_params() Joe Perches <joe@perches.com> - 2016-08-21 22:00 +0200
[PATCH v2 0/2] ALSA: compress: Fine-tuning for snd_compr_set_params() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-22 10:40 +0200
[PATCH v2 1/2] ALSA: compress: Restructure source code around an if statement in snd_compr_set_params() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-22 10:40 +0200
[PATCH v2 2/2] ALSA: compress: Use memdup_user() rather than duplicating its implementation SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-22 10:50 +0200
Re: [PATCH v2 0/2] ALSA: compress: Fine-tuning for snd_compr_set_params() Vinod Koul <vinod.koul@intel.com> - 2016-08-23 06:00 +0200
Re: [PATCH 2/2] ALSA: compress: Reduce the scope for two variables in snd_compr_set_params() Julia Lawall <julia.lawall@lip6.fr> - 2016-08-21 22:40 +0200
Re: [PATCH 2/2] ALSA: compress: Reduce the scope for two variables in snd_compr_set_params() Vinod Koul <vinod.koul@intel.com> - 2016-08-22 07:00 +0200
Re: [PATCH 2/2] ALSA: compress: Reduce the scope for two variables in snd_compr_set_params() walter harms <wharms@bfs.de> - 2016-08-22 09:30 +0200
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-08-21 21:50 +0200 |
| Subject | [PATCH 0/2] ALSA: compress: Fine-tuning for snd_compr_set_params() |
| Message-ID | <s8GUO-4BF-5@gated-at.bofh.it> |
From: Markus Elfring <elfring@users.sourceforge.net> Date: Sun, 21 Aug 2016 21:35:43 +0200 A few update suggestions were taken into account from static source code analysis. Markus Elfring (2): Use memdup_user() Reduce the scope for two variables sound/core/compress_offload.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) -- 2.9.3
[toc] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-08-21 21:50 +0200 |
| Subject | [PATCH 1/2] ALSA: compress: Use memdup_user() rather than duplicating its implementation |
| Message-ID | <s8GUO-4BF-7@gated-at.bofh.it> |
| In reply to | #1467223 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 21:02:06 +0200
Reuse existing functionality from memdup_user() instead of keeping
duplicate source code.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
sound/core/compress_offload.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index 2c49848..583d407 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -553,13 +553,9 @@ snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
* we should allow parameter change only when stream has been
* opened not in other cases
*/
- params = kmalloc(sizeof(*params), GFP_KERNEL);
- if (!params)
- return -ENOMEM;
- if (copy_from_user(params, (void __user *)arg, sizeof(*params))) {
- retval = -EFAULT;
- goto out;
- }
+ params = memdup_user((void __user *)arg, sizeof(*params));
+ if (IS_ERR(params))
+ return PTR_ERR(params);
retval = snd_compress_check_input(params);
if (retval)
--
2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Vinod Koul <vinod.koul@intel.com> |
|---|---|
| Date | 2016-08-22 07:00 +0200 |
| Subject | Re: [PATCH 1/2] ALSA: compress: Use memdup_user() rather than duplicating its implementation |
| Message-ID | <s8Pv3-1AV-3@gated-at.bofh.it> |
| In reply to | #1467224 |
On Sun, Aug 21, 2016 at 09:43:22PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 21 Aug 2016 21:02:06 +0200
>
> Reuse existing functionality from memdup_user() instead of keeping
> duplicate source code.
>
> This issue was detected by using the Coccinelle software.
It usually helps to have Coccinelle script in changelog.
But nevertheless
Acked-by: Vinod Koul <vinod.koul@intel.com>
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> sound/core/compress_offload.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
> index 2c49848..583d407 100644
> --- a/sound/core/compress_offload.c
> +++ b/sound/core/compress_offload.c
> @@ -553,13 +553,9 @@ snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
> * we should allow parameter change only when stream has been
> * opened not in other cases
> */
> - params = kmalloc(sizeof(*params), GFP_KERNEL);
> - if (!params)
> - return -ENOMEM;
> - if (copy_from_user(params, (void __user *)arg, sizeof(*params))) {
> - retval = -EFAULT;
> - goto out;
> - }
> + params = memdup_user((void __user *)arg, sizeof(*params));
> + if (IS_ERR(params))
> + return PTR_ERR(params);
>
> retval = snd_compress_check_input(params);
> if (retval)
> --
> 2.9.3
>
--
~Vinod
[toc] | [prev] | [next] | [standalone]
| From | Takashi Iwai <tiwai@suse.de> |
|---|---|
| Date | 2016-08-22 14:10 +0200 |
| Subject | Re: [alsa-devel] [PATCH 1/2] ALSA: compress: Use memdup_user() rather than duplicating its implementation |
| Message-ID | <s8Wdc-66j-23@gated-at.bofh.it> |
| In reply to | #1467224 |
On Sun, 21 Aug 2016 21:43:22 +0200, SF Markus Elfring wrote: > > From: Markus Elfring <elfring@users.sourceforge.net> > Date: Sun, 21 Aug 2016 21:02:06 +0200 > > Reuse existing functionality from memdup_user() instead of keeping > duplicate source code. > > This issue was detected by using the Coccinelle software. > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Applied this one, but the second patch won't be, since other people seem to disagree with the usefulness. thanks, Takashi
[toc] | [prev] | [next] | [standalone]
| From | Vinod Koul <vinod.koul@intel.com> |
|---|---|
| Date | 2016-08-23 05:50 +0200 |
| Subject | Re: [alsa-devel] [PATCH 1/2] ALSA: compress: Use memdup_user() rather than duplicating its implementation |
| Message-ID | <s9aSR-6Y5-3@gated-at.bofh.it> |
| In reply to | #1467574 |
On Mon, Aug 22, 2016 at 02:05:43PM +0200, Takashi Iwai wrote: > On Sun, 21 Aug 2016 21:43:22 +0200, > SF Markus Elfring wrote: > > > > From: Markus Elfring <elfring@users.sourceforge.net> > > Date: Sun, 21 Aug 2016 21:02:06 +0200 > > > > Reuse existing functionality from memdup_user() instead of keeping > > duplicate source code. > > > > This issue was detected by using the Coccinelle software. > > > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> > > Applied this one, but the second patch won't be, since other people > seem to disagree with the usefulness. I see a v2 as well discarding patch 2 here and some other changes -- ~Vinod
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-08-21 21:50 +0200 |
| Subject | [PATCH 2/2] ALSA: compress: Reduce the scope for two variables in snd_compr_set_params() |
| Message-ID | <s8GUO-4BF-13@gated-at.bofh.it> |
| In reply to | #1467223 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 21:26:18 +0200
Reduce the scope for the local variables to an if branch.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
sound/core/compress_offload.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index 583d407..b43aec5 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -545,14 +545,14 @@ static int snd_compress_check_input(struct snd_compr_params *params)
static int
snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
{
- struct snd_compr_params *params;
- int retval;
-
if (stream->runtime->state == SNDRV_PCM_STATE_OPEN) {
/*
* we should allow parameter change only when stream has been
* opened not in other cases
*/
+ int retval;
+ struct snd_compr_params *params;
+
params = memdup_user((void __user *)arg, sizeof(*params));
if (IS_ERR(params))
return PTR_ERR(params);
@@ -578,12 +578,12 @@ snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
stream->runtime->state = SNDRV_PCM_STATE_SETUP;
else
stream->runtime->state = SNDRV_PCM_STATE_PREPARED;
+out:
+ kfree(params);
+ return retval;
} else {
return -EPERM;
}
-out:
- kfree(params);
- return retval;
}
static int
--
2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Joe Perches <joe@perches.com> |
|---|---|
| Date | 2016-08-21 22:00 +0200 |
| Subject | Re: [PATCH 2/2] ALSA: compress: Reduce the scope for two variables in snd_compr_set_params() |
| Message-ID | <s8H4u-4F3-33@gated-at.bofh.it> |
| In reply to | #1467225 |
On Sun, 2016-08-21 at 21:45 +0200, SF Markus Elfring wrote:
> Reduce the scope for the local variables to an if branch.
[]
> diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
[]
> @@ -545,14 +545,14 @@ static int snd_compress_check_input(struct snd_compr_params *params)
> static int
> snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
> {
> - struct snd_compr_params *params;
> - int retval;
> -
> if (stream->runtime->state == SNDRV_PCM_STATE_OPEN) {
Likely better not reducing variable scope but changing:
if (stream->runtime->state == SNDRV_PCM_STATE_OPEN)
to
if (stream->runtime->state != SNDRV_PCM_STATE_OPEN)
return -EPERM;
and unindenting the remainder of the code one level instead.
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-08-22 10:40 +0200 |
| Subject | [PATCH v2 0/2] ALSA: compress: Fine-tuning for snd_compr_set_params() |
| Message-ID | <s8SVY-3V6-9@gated-at.bofh.it> |
| In reply to | #1467231 |
From: Markus Elfring <elfring@users.sourceforge.net> Date: Mon, 22 Aug 2016 10:27:01 +0200 A few update suggestions were taken into account from static source code analysis. Markus Elfring (2): Restructure source code around an if statement Use memdup_user() sound/core/compress_offload.c | 58 +++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 32 deletions(-) -- 2.9.3
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-08-22 10:40 +0200 |
| Subject | [PATCH v2 1/2] ALSA: compress: Restructure source code around an if statement in snd_compr_set_params() |
| Message-ID | <s8SVY-3V6-11@gated-at.bofh.it> |
| In reply to | #1467458 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 22 Aug 2016 10:01:52 +0200
* Reverse a condition check.
* Reduce the indentation one level then for some source code
from a previous if branch.
Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
sound/core/compress_offload.c | 62 +++++++++++++++++++++----------------------
1 file changed, 30 insertions(+), 32 deletions(-)
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index 2c49848..a10d139 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -548,43 +548,41 @@ snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
struct snd_compr_params *params;
int retval;
- if (stream->runtime->state == SNDRV_PCM_STATE_OPEN) {
- /*
- * we should allow parameter change only when stream has been
- * opened not in other cases
- */
- params = kmalloc(sizeof(*params), GFP_KERNEL);
- if (!params)
- return -ENOMEM;
- if (copy_from_user(params, (void __user *)arg, sizeof(*params))) {
- retval = -EFAULT;
- goto out;
- }
+ if (stream->runtime->state != SNDRV_PCM_STATE_OPEN)
+ return -EPERM;
+ /*
+ * we should allow parameter change only when stream has been
+ * opened not in other cases
+ */
+ params = kmalloc(sizeof(*params), GFP_KERNEL);
+ if (!params)
+ return -ENOMEM;
+ if (copy_from_user(params, (void __user *)arg, sizeof(*params))) {
+ retval = -EFAULT;
+ goto out;
+ }
- retval = snd_compress_check_input(params);
- if (retval)
- goto out;
+ retval = snd_compress_check_input(params);
+ if (retval)
+ goto out;
- retval = snd_compr_allocate_buffer(stream, params);
- if (retval) {
- retval = -ENOMEM;
- goto out;
- }
+ retval = snd_compr_allocate_buffer(stream, params);
+ if (retval) {
+ retval = -ENOMEM;
+ goto out;
+ }
- retval = stream->ops->set_params(stream, params);
- if (retval)
- goto out;
+ retval = stream->ops->set_params(stream, params);
+ if (retval)
+ goto out;
- stream->metadata_set = false;
- stream->next_track = false;
+ stream->metadata_set = false;
+ stream->next_track = false;
- if (stream->direction == SND_COMPRESS_PLAYBACK)
- stream->runtime->state = SNDRV_PCM_STATE_SETUP;
- else
- stream->runtime->state = SNDRV_PCM_STATE_PREPARED;
- } else {
- return -EPERM;
- }
+ if (stream->direction == SND_COMPRESS_PLAYBACK)
+ stream->runtime->state = SNDRV_PCM_STATE_SETUP;
+ else
+ stream->runtime->state = SNDRV_PCM_STATE_PREPARED;
out:
kfree(params);
return retval;
--
2.9.3
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-08-22 10:50 +0200 |
| Subject | [PATCH v2 2/2] ALSA: compress: Use memdup_user() rather than duplicating its implementation |
| Message-ID | <s8T5E-3Zg-17@gated-at.bofh.it> |
| In reply to | #1467458 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 22 Aug 2016 10:12:37 +0200
Reuse existing functionality from memdup_user() instead of keeping
duplicate source code.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
sound/core/compress_offload.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index a10d139..786989b 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -554,13 +554,9 @@ snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
* we should allow parameter change only when stream has been
* opened not in other cases
*/
- params = kmalloc(sizeof(*params), GFP_KERNEL);
- if (!params)
- return -ENOMEM;
- if (copy_from_user(params, (void __user *)arg, sizeof(*params))) {
- retval = -EFAULT;
- goto out;
- }
+ params = memdup_user((void __user *)arg, sizeof(*params));
+ if (IS_ERR(params))
+ return PTR_ERR(params);
retval = snd_compress_check_input(params);
if (retval)
--
2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Vinod Koul <vinod.koul@intel.com> |
|---|---|
| Date | 2016-08-23 06:00 +0200 |
| Subject | Re: [PATCH v2 0/2] ALSA: compress: Fine-tuning for snd_compr_set_params() |
| Message-ID | <s9b2x-71k-5@gated-at.bofh.it> |
| In reply to | #1467458 |
On Mon, Aug 22, 2016 at 10:34:19AM +0200, SF Markus Elfring wrote: > From: Markus Elfring <elfring@users.sourceforge.net> > Date: Mon, 22 Aug 2016 10:27:01 +0200 > > A few update suggestions were taken into account > from static source code analysis. Both: Acked-by: Vinod Koul <vinod.koul@intel.com> -- ~Vinod
[toc] | [prev] | [next] | [standalone]
| From | Julia Lawall <julia.lawall@lip6.fr> |
|---|---|
| Date | 2016-08-21 22:40 +0200 |
| Subject | Re: [PATCH 2/2] ALSA: compress: Reduce the scope for two variables in snd_compr_set_params() |
| Message-ID | <s8HHb-58A-13@gated-at.bofh.it> |
| In reply to | #1467225 |
On Sun, 21 Aug 2016, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 21 Aug 2016 21:26:18 +0200
>
> Reduce the scope for the local variables to an if branch.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> sound/core/compress_offload.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
> index 583d407..b43aec5 100644
> --- a/sound/core/compress_offload.c
> +++ b/sound/core/compress_offload.c
> @@ -545,14 +545,14 @@ static int snd_compress_check_input(struct snd_compr_params *params)
> static int
> snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
> {
> - struct snd_compr_params *params;
> - int retval;
> -
> if (stream->runtime->state == SNDRV_PCM_STATE_OPEN) {
> /*
> * we should allow parameter change only when stream has been
> * opened not in other cases
> */
> + int retval;
> + struct snd_compr_params *params;
I don't like this at all. Local variables should be at the top of the
function, not hiding under 4 lines of comments in the middle of the code.
julia
> +
> params = memdup_user((void __user *)arg, sizeof(*params));
> if (IS_ERR(params))
> return PTR_ERR(params);
> @@ -578,12 +578,12 @@ snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
> stream->runtime->state = SNDRV_PCM_STATE_SETUP;
> else
> stream->runtime->state = SNDRV_PCM_STATE_PREPARED;
> +out:
> + kfree(params);
> + return retval;
> } else {
> return -EPERM;
> }
> -out:
> - kfree(params);
> - return retval;
> }
>
> static int
> --
> 2.9.3
>
>
[toc] | [prev] | [next] | [standalone]
| From | Vinod Koul <vinod.koul@intel.com> |
|---|---|
| Date | 2016-08-22 07:00 +0200 |
| Subject | Re: [PATCH 2/2] ALSA: compress: Reduce the scope for two variables in snd_compr_set_params() |
| Message-ID | <s8Pv3-1AV-1@gated-at.bofh.it> |
| In reply to | #1467241 |
On Sun, Aug 21, 2016 at 04:36:22PM -0400, Julia Lawall wrote:
>
>
> On Sun, 21 Aug 2016, SF Markus Elfring wrote:
>
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Sun, 21 Aug 2016 21:26:18 +0200
> >
> > Reduce the scope for the local variables to an if branch.
> >
> > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> > ---
> > sound/core/compress_offload.c | 12 ++++++------
> > 1 file changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
> > index 583d407..b43aec5 100644
> > --- a/sound/core/compress_offload.c
> > +++ b/sound/core/compress_offload.c
> > @@ -545,14 +545,14 @@ static int snd_compress_check_input(struct snd_compr_params *params)
> > static int
> > snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
> > {
> > - struct snd_compr_params *params;
> > - int retval;
> > -
> > if (stream->runtime->state == SNDRV_PCM_STATE_OPEN) {
> > /*
> > * we should allow parameter change only when stream has been
> > * opened not in other cases
> > */
> > + int retval;
> > + struct snd_compr_params *params;
>
> I don't like this at all. Local variables should be at the top of the
> function, not hiding under 4 lines of comments in the middle of the code.
I agree with you this, it doesn't help IMO as well
--
~Vinod
[toc] | [prev] | [next] | [standalone]
| From | walter harms <wharms@bfs.de> |
|---|---|
| Date | 2016-08-22 09:30 +0200 |
| Subject | Re: [PATCH 2/2] ALSA: compress: Reduce the scope for two variables in snd_compr_set_params() |
| Message-ID | <s8RQd-3fx-9@gated-at.bofh.it> |
| In reply to | #1467225 |
Am 21.08.2016 21:45, schrieb SF Markus Elfring:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 21 Aug 2016 21:26:18 +0200
>
> Reduce the scope for the local variables to an if branch.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> sound/core/compress_offload.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
> index 583d407..b43aec5 100644
> --- a/sound/core/compress_offload.c
> +++ b/sound/core/compress_offload.c
> @@ -545,14 +545,14 @@ static int snd_compress_check_input(struct snd_compr_params *params)
> static int
> snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
> {
> - struct snd_compr_params *params;
> - int retval;
> -
> if (stream->runtime->state == SNDRV_PCM_STATE_OPEN) {
> /*
> * we should allow parameter change only when stream has been
> * opened not in other cases
> */
> + int retval;
> + struct snd_compr_params *params;
> +
> params = memdup_user((void __user *)arg, sizeof(*params));
> if (IS_ERR(params))
> return PTR_ERR(params);
> @@ -578,12 +578,12 @@ snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
> stream->runtime->state = SNDRV_PCM_STATE_SETUP;
> else
> stream->runtime->state = SNDRV_PCM_STATE_PREPARED;
> +out:
> + kfree(params);
> + return retval;
> } else {
> return -EPERM;
> }
> -out:
> - kfree(params);
> - return retval;
> }
>
> static int
if would make sense to have
if (stream->runtime->state != SNDRV_PCM_STATE_OPEN)
return -EPERM;
and read adjust the indent.
just my 2 cents
re,
wh
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web