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:	Mon, 20 Jun 2011 22:50:38 +0300
From:	Alexey Dobriyan <adobriyan@...il.com>
To:	Peter Huewe <peterhuewe@....de>
Cc:	Samuel Ortiz <sameo@...ux.intel.com>,
	Srinidhi Kasagar <srinidhi.kasagar@...ricsson.com>,
	Linus Walleij <linus.walleij@...ricsson.com>,
	Mark Brown <broonie@...nsource.wolfsonmicro.com>,
	Ian Lartey <ian@...nsource.wolfsonmicro.com>,
	Dimitris Papastamos <dp@...nsource.wolfsonmicro.com>,
	linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
	kernel-janitors@...r.kernel.org
Subject: Re: [PATCH 1/2 v2] mfd/ab3550: Convert to kstrtou8_from_user

On Mon, Jun 20, 2011 at 09:46:28PM +0200, Peter Huewe wrote:
> @@ -923,27 +916,16 @@ static ssize_t ab3550_address_write(struct file *file,
>  	size_t count, loff_t *ppos)
>  {
>  	struct ab3550 *ab = ((struct seq_file *)(file->private_data))->private;
> -	char buf[32];
> -	int buf_size;
> -	unsigned long user_address;
> +	u8 user_address;
>  	int err;
>  
> -	/* Get userspace string and assure termination */
> -	buf_size = min(count, (sizeof(buf) - 1));
> -	if (copy_from_user(buf, user_buf, buf_size))
> -		return -EFAULT;
> -	buf[buf_size] = 0;
> -
> -	err = strict_strtoul(buf, 0, &user_address);
> +	/* Get userspace string and convert to number */
> +	err = kstrtou8_from_user(user_buf, count, 0, &user_address);
>  	if (err)
> -		return -EINVAL;
> -	if (user_address > 0xff) {
> -		dev_err(&ab->i2c_client[0]->dev,
> -			"debugfs error input > 0xff\n");
> -		return -EINVAL;
> -	}
> +		return err;
> +
>  	ab->debug_address = user_address;
> -	return buf_size;
> +	return count;

You don't need temporary variable and should write straight to final location,
because kstrto* functions will never write to result unless it was converted
successfully.
--
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