Skip to content

Commit 8cc5e9b

Browse files
dlechjic23
authored andcommitted
iio: imu: inv_mpu6050: use = { } instead of memset()
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-17-ebb2d0a24302@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent cae94ba commit 8cc5e9b

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,10 @@ int inv_mpu_acpi_create_mux_client(struct i2c_client *client)
130130

131131
st->mux_client = NULL;
132132
if (adev) {
133-
struct i2c_board_info info;
133+
struct i2c_board_info info = { };
134134
struct i2c_client *mux_client;
135135
int ret = -1;
136136

137-
memset(&info, 0, sizeof(info));
138-
139137
dmi_check_system(inv_mpu_dev_list);
140138
switch (matched_product_name) {
141139
case INV_MPU_ASUS_T100TA:

drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p)
5050
u16 fifo_count;
5151
u32 fifo_period;
5252
s64 timestamp;
53-
u8 data[INV_MPU6050_OUTPUT_DATA_SIZE] __aligned(8);
53+
/* clear internal data buffer for avoiding kernel data leak */
54+
u8 data[INV_MPU6050_OUTPUT_DATA_SIZE] __aligned(8) = { };
5455
size_t i, nb;
5556

5657
mutex_lock(&st->lock);
@@ -103,9 +104,6 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p)
103104
inv_sensors_timestamp_interrupt(&st->timestamp, 1, pf->timestamp);
104105
inv_sensors_timestamp_apply_odr(&st->timestamp, fifo_period, 1, 0);
105106

106-
/* clear internal data buffer for avoiding kernel data leak */
107-
memset(data, 0, sizeof(data));
108-
109107
/* read all data once and process every samples */
110108
result = regmap_noinc_read(st->map, st->reg->fifo_r_w, st->data, fifo_count);
111109
if (result)

0 commit comments

Comments
 (0)