aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2012-11-27 02:31:00 -0500
committerJonathan Cameron <jic23@kernel.org>2012-11-30 08:10:16 -0500
commitafc3a57a2efc4af623df07771c6b1aef15158537 (patch)
tree614b81a5e5c6e18c9b03e4e1fd8e83bf46423daa /drivers/iio
parent12660138b491b56d1e70333547912c56741be5e8 (diff)
iio:imu: adis16480: show_firmware() buffer too small
Smatch complains that snprintf() returns the number of characters, not counting the NUL terminator, which *would* have been printed if there were enough space. In other words the return value could be more than sizeof(buf). In this case, we are printing something like "ff.ff\n" which is at most 6 characters and a NUL so that's not an issue. I changed snprintf() to scnprintf() to silence the warning. But since the buffer doesn't include space for the NUL terminator, we need to make it bigger or the "\n" will be truncated off. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-By: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/imu/adis16480.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c
index a080b3515015..150d7faa9275 100644
--- a/drivers/iio/imu/adis16480.c
+++ b/drivers/iio/imu/adis16480.c
@@ -125,7 +125,7 @@ static ssize_t adis16480_show_firmware_revision(struct file *file,
125 char __user *userbuf, size_t count, loff_t *ppos) 125 char __user *userbuf, size_t count, loff_t *ppos)
126{ 126{
127 struct adis16480 *adis16480 = file->private_data; 127 struct adis16480 *adis16480 = file->private_data;
128 char buf[6]; 128 char buf[7];
129 size_t len; 129 size_t len;
130 u16 rev; 130 u16 rev;
131 int ret; 131 int ret;
@@ -134,7 +134,7 @@ static ssize_t adis16480_show_firmware_revision(struct file *file,
134 if (ret < 0) 134 if (ret < 0)
135 return ret; 135 return ret;
136 136
137 len = snprintf(buf, sizeof(buf), "%x.%x\n", rev >> 8, rev & 0xff); 137 len = scnprintf(buf, sizeof(buf), "%x.%x\n", rev >> 8, rev & 0xff);
138 138
139 return simple_read_from_buffer(userbuf, count, ppos, buf, len); 139 return simple_read_from_buffer(userbuf, count, ppos, buf, len);
140} 140}