aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2015-08-08 15:16:42 -0400
committerJonathan Cameron <jic23@kernel.org>2015-10-03 05:28:24 -0400
commiteda7d0f38aaf50dbb2a2de15e8db386c4f6f65fc (patch)
tree4539f2e5a45ebfd1c861adf5144b179450c6ca47
parent61fd56309165d4790f99462d893b099f0b07312a (diff)
iio: accel: sca3000: memory corruption in sca3000_read_first_n_hw_rb()
"num_read" is in byte units but we are write u16s so we end up write twice as much as intended. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r--drivers/staging/iio/accel/sca3000_ring.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/staging/iio/accel/sca3000_ring.c b/drivers/staging/iio/accel/sca3000_ring.c
index 23685e74917e..bd2c69f85949 100644
--- a/drivers/staging/iio/accel/sca3000_ring.c
+++ b/drivers/staging/iio/accel/sca3000_ring.c
@@ -116,7 +116,7 @@ static int sca3000_read_first_n_hw_rb(struct iio_buffer *r,
116 if (ret) 116 if (ret)
117 goto error_ret; 117 goto error_ret;
118 118
119 for (i = 0; i < num_read; i++) 119 for (i = 0; i < num_read / sizeof(u16); i++)
120 *(((u16 *)rx) + i) = be16_to_cpup((__be16 *)rx + i); 120 *(((u16 *)rx) + i) = be16_to_cpup((__be16 *)rx + i);
121 121
122 if (copy_to_user(buf, rx, num_read)) 122 if (copy_to_user(buf, rx, num_read))