mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 19:08:57 +09:00
iio: imu: inv_icm42600: use = { } instead of memset()
[ Upstream commit 352112e2d9aab6a156c2803ae14eb89a9fd93b7d ]
Use { } instead of memset() to zero-initialize stack memory to simplify
the code.
Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20250611-iio-zero-init-stack-with-instead-of-memset-v1-16-ebb2d0a24302@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Stable-dep-of: dfdc31e7ccf3 ("iio: imu: inv_icm42600: change invalid data error to -EBUSY")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
f52d8ba432
commit
ec3310a516
@@ -755,7 +755,8 @@ int inv_icm42600_accel_parse_fifo(struct iio_dev *indio_dev)
|
||||
const int8_t *temp;
|
||||
unsigned int odr;
|
||||
int64_t ts_val;
|
||||
struct inv_icm42600_accel_buffer buffer;
|
||||
/* buffer is copied to userspace, zeroing it to avoid any data leak */
|
||||
struct inv_icm42600_accel_buffer buffer = { };
|
||||
|
||||
/* parse all fifo packets */
|
||||
for (i = 0, no = 0; i < st->fifo.count; i += size, ++no) {
|
||||
@@ -774,8 +775,6 @@ int inv_icm42600_accel_parse_fifo(struct iio_dev *indio_dev)
|
||||
inv_sensors_timestamp_apply_odr(ts, st->fifo.period,
|
||||
st->fifo.nb.total, no);
|
||||
|
||||
/* buffer is copied to userspace, zeroing it to avoid any data leak */
|
||||
memset(&buffer, 0, sizeof(buffer));
|
||||
memcpy(&buffer.accel, accel, sizeof(buffer.accel));
|
||||
/* convert 8 bits FIFO temperature in high resolution format */
|
||||
buffer.temp = temp ? (*temp * 64) : 0;
|
||||
|
||||
@@ -767,7 +767,8 @@ int inv_icm42600_gyro_parse_fifo(struct iio_dev *indio_dev)
|
||||
const int8_t *temp;
|
||||
unsigned int odr;
|
||||
int64_t ts_val;
|
||||
struct inv_icm42600_gyro_buffer buffer;
|
||||
/* buffer is copied to userspace, zeroing it to avoid any data leak */
|
||||
struct inv_icm42600_gyro_buffer buffer = { };
|
||||
|
||||
/* parse all fifo packets */
|
||||
for (i = 0, no = 0; i < st->fifo.count; i += size, ++no) {
|
||||
@@ -786,8 +787,6 @@ int inv_icm42600_gyro_parse_fifo(struct iio_dev *indio_dev)
|
||||
inv_sensors_timestamp_apply_odr(ts, st->fifo.period,
|
||||
st->fifo.nb.total, no);
|
||||
|
||||
/* buffer is copied to userspace, zeroing it to avoid any data leak */
|
||||
memset(&buffer, 0, sizeof(buffer));
|
||||
memcpy(&buffer.gyro, gyro, sizeof(buffer.gyro));
|
||||
/* convert 8 bits FIFO temperature in high resolution format */
|
||||
buffer.temp = temp ? (*temp * 64) : 0;
|
||||
|
||||
Reference in New Issue
Block a user