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, 30 Apr 2012 22:01:54 +0200
From:	Lars-Peter Clausen <lars@...afoo.de>
To:	joseph daniel <josephdanielwalter@...il.com>
CC:	Jonathan Cameron <jic23@....ac.uk>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Wolfram Sang <w.sang@...gutronix.de>,
	Paul Gortmaker <paul.gortmaker@...driver.com>,
	linux-iio@...r.kernel.org, devel@...verdev.osuosl.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] staging/iio/meter: fix the coding style problem

On 04/30/2012 09:26 PM, joseph daniel wrote:
> Signed-off-by: joseph daniel <josephdanielwalter@...il.com>
> ---
> Hi Lars,
> 	Thanks for review. how about the below change?
>  drivers/staging/iio/meter/ade7854-i2c.c |    6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/iio/meter/ade7854-i2c.c b/drivers/staging/iio/meter/ade7854-i2c.c
> index 1e1faa0..52bdb05 100644
> --- a/drivers/staging/iio/meter/ade7854-i2c.c
> +++ b/drivers/staging/iio/meter/ade7854-i2c.c
> @@ -181,6 +181,7 @@ static int ade7854_i2c_read_reg_32(struct device *dev,
>  {
>  	struct iio_dev *indio_dev = dev_get_drvdata(dev);
>  	struct ade7854_state *st = iio_priv(indio_dev);
> +	uint32_t value;
>  	int ret;
>  
>  	mutex_lock(&st->buf_lock);
> @@ -195,7 +196,10 @@ static int ade7854_i2c_read_reg_32(struct device *dev,
>  	if (ret)
>  		goto out;
>  
> -	*val = (st->rx[0] << 24) | (st->rx[1] << 16) | (st->rx[2] << 8) | st->rx[3];
> +	memcpy(&value, st->rx, sizeof(uint32_t));
> +

Uhm, yes, you are right st->rx is unaligned. The memcpy is not necessary though
if you use get_unaligned_be32. Sorry for the pointer to the wrong function.

Btw. there are a few other locations in this driver which could use the
put_unaligned_be* and get_unaligned_be* functions. Would be great if you could
convert these as well.

> +	*val = be32_to_cpu(value);
> +
>  out:
>  	mutex_unlock(&st->buf_lock);
>  	return ret;

--
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