lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sun, 21 Aug 2016 16:36:22 -0400 (EDT)
From:   Julia Lawall <julia.lawall@...6.fr>
To:     SF Markus Elfring <elfring@...rs.sourceforge.net>
cc:     alsa-devel@...a-project.org, Jaroslav Kysela <perex@...ex.cz>,
        Takashi Iwai <tiwai@...e.com>,
        Vinod Koul <vinod.koul@...el.com>,
        LKML <linux-kernel@...r.kernel.org>,
        kernel-janitors@...r.kernel.org
Subject: Re: [PATCH 2/2] ALSA: compress: Reduce the scope for two variables
 in snd_compr_set_params()



On Sun, 21 Aug 2016, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@...rs.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@...rs.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
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ