Commit 2684d50
committed
iio:light:ltr501 Fix timestamp alignment issue.
One of a class of bugs pointed out by Lars in a recent review.
iio_push_to_buffers_with_timestamp assumes the buffer used is aligned
to the size of the timestamp (8 bytes). This is not guaranteed in
this driver which uses an array of smaller elements on the stack.
Here we use a structure on the stack. The driver already did an
explicit memset so no data leak was possible.
Forced alignment of ts is not strictly necessary but probably makes
the code slightly less fragile.
Note there has been some rework in this driver of the years, so no
way this will apply cleanly all the way back.
Fixes: 2690be9 ("iio: Add Lite-On ltr501 ambient light / proximity sensor driver")
Reported-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: <Stable@vger.kernel.org>1 parent 5236288 commit 2684d50
1 file changed
Lines changed: 9 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1243 | 1243 | | |
1244 | 1244 | | |
1245 | 1245 | | |
1246 | | - | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
1247 | 1250 | | |
1248 | 1251 | | |
1249 | 1252 | | |
1250 | 1253 | | |
1251 | 1254 | | |
1252 | | - | |
| 1255 | + | |
1253 | 1256 | | |
1254 | 1257 | | |
1255 | 1258 | | |
| |||
1268 | 1271 | | |
1269 | 1272 | | |
1270 | 1273 | | |
1271 | | - | |
| 1274 | + | |
1272 | 1275 | | |
1273 | | - | |
| 1276 | + | |
1274 | 1277 | | |
1275 | 1278 | | |
1276 | 1279 | | |
1277 | 1280 | | |
1278 | 1281 | | |
1279 | 1282 | | |
1280 | 1283 | | |
1281 | | - | |
| 1284 | + | |
1282 | 1285 | | |
1283 | 1286 | | |
1284 | | - | |
| 1287 | + | |
1285 | 1288 | | |
1286 | 1289 | | |
1287 | 1290 | | |
| |||
0 commit comments