Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

David Lechner and committed by
Jonathan Cameron
3ee3c09d 352112e2

+3 -7
+1 -3
drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
··· 130 130 131 131 st->mux_client = NULL; 132 132 if (adev) { 133 - struct i2c_board_info info; 133 + struct i2c_board_info info = { }; 134 134 struct i2c_client *mux_client; 135 135 int ret = -1; 136 - 137 - memset(&info, 0, sizeof(info)); 138 136 139 137 dmi_check_system(inv_mpu_dev_list); 140 138 switch (matched_product_name) {
+2 -4
drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c
··· 50 50 u16 fifo_count; 51 51 u32 fifo_period; 52 52 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) = { }; 54 55 size_t i, nb; 55 56 56 57 mutex_lock(&st->lock); ··· 103 102 fifo_period = NSEC_PER_SEC / INV_MPU6050_DIVIDER_TO_FIFO_RATE(st->chip_config.divider); 104 103 inv_sensors_timestamp_interrupt(&st->timestamp, 1, pf->timestamp); 105 104 inv_sensors_timestamp_apply_odr(&st->timestamp, fifo_period, 1, 0); 106 - 107 - /* clear internal data buffer for avoiding kernel data leak */ 108 - memset(data, 0, sizeof(data)); 109 105 110 106 /* read all data once and process every samples */ 111 107 result = regmap_noinc_read(st->map, st->reg->fifo_r_w, st->data, fifo_count);