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:	Thu, 20 Jun 2013 20:02:57 +0800
From:	Chen Gang <gang.chen@...anux.com>
To:	Thomas Gleixner <tglx@...utronix.de>,
	'Jiri Kosina' <trivial@...nel.org>
CC:	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] kernel/itimer.c: beautify code, not need check 'value',
 so save one instruction, simpler and easier for readers.


Oh, sorry, maybe it is a trivial patch, also need send to
trivial@...nel.org.


On 06/20/2013 07:26 PM, Chen Gang wrote:
> 
> Since copy_to_user() will check 'value', we do not need check it outside
> again,  so can save one comparing instruction at least.
> 
> Also can let code simpler and easier for readers: if checking parameter
> 'value', it will easily lead readers to think about why not return
> -EINVAL instead of -EFAULT, when checking parameter failed.
> 
> Signed-off-by: Chen Gang <gang.chen@...anux.com>
> ---
>  kernel/itimer.c |   13 ++++++-------
>  1 files changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/kernel/itimer.c b/kernel/itimer.c
> index 8d262b4..3b12271 100644
> --- a/kernel/itimer.c
> +++ b/kernel/itimer.c
> @@ -102,15 +102,14 @@ int do_getitimer(int which, struct itimerval *value)
>  
>  SYSCALL_DEFINE2(getitimer, int, which, struct itimerval __user *, value)
>  {
> -	int error = -EFAULT;
> +	int error;
>  	struct itimerval get_buffer;
>  
> -	if (value) {
> -		error = do_getitimer(which, &get_buffer);
> -		if (!error &&
> -		    copy_to_user(value, &get_buffer, sizeof(get_buffer)))
> -			error = -EFAULT;
> -	}
> +	error = do_getitimer(which, &get_buffer);
> +	if (!error &&
> +	    copy_to_user(value, &get_buffer, sizeof(get_buffer)))
> +		error = -EFAULT;
> +
>  	return error;
>  }
>  
> 


-- 
Chen Gang

Asianux Corporation
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ