]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iio: imu: inv_mpu6050: use = { } instead of memset()
authorDavid Lechner <dlechner@baylibre.com>
Wed, 11 Jun 2025 22:39:09 +0000 (17:39 -0500)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Thu, 26 Jun 2025 18:32:56 +0000 (19:32 +0100)
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>
drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c

index a9bcf02e5b43fac0e210c6f78816a3c042b52f3d..460792ed27e03192464066dfa088734f0b6b1cdf 100644 (file)
@@ -130,12 +130,10 @@ int inv_mpu_acpi_create_mux_client(struct i2c_client *client)
 
        st->mux_client = NULL;
        if (adev) {
-               struct i2c_board_info info;
+               struct i2c_board_info info = { };
                struct i2c_client *mux_client;
                int ret = -1;
 
-               memset(&info, 0, sizeof(info));
-
                dmi_check_system(inv_mpu_dev_list);
                switch (matched_product_name) {
                case INV_MPU_ASUS_T100TA:
index 273196e647a2b5a4860e18cfa34a088c773540e4..c4c11124f92f7fa6730e7443e3be67d920b8c115 100644 (file)
@@ -50,7 +50,8 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p)
        u16 fifo_count;
        u32 fifo_period;
        s64 timestamp;
-       u8 data[INV_MPU6050_OUTPUT_DATA_SIZE] __aligned(8);
+       /* clear internal data buffer for avoiding kernel data leak */
+       u8 data[INV_MPU6050_OUTPUT_DATA_SIZE] __aligned(8) = { };
        size_t i, nb;
 
        mutex_lock(&st->lock);
@@ -103,9 +104,6 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p)
        inv_sensors_timestamp_interrupt(&st->timestamp, 1, pf->timestamp);
        inv_sensors_timestamp_apply_odr(&st->timestamp, fifo_period, 1, 0);
 
-       /* clear internal data buffer for avoiding kernel data leak */
-       memset(data, 0, sizeof(data));
-
        /* read all data once and process every samples */
        result = regmap_noinc_read(st->map, st->reg->fifo_r_w, st->data, fifo_count);
        if (result)