]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iio: pressure: bmp280: use = { } instead of memset()
authorDavid Lechner <dlechner@baylibre.com>
Wed, 11 Jun 2025 22:39:15 +0000 (17:39 -0500)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Thu, 26 Jun 2025 18:32:57 +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-23-ebb2d0a24302@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/pressure/bmp280-core.c

index f37f20776c89173b0b2a8e28be0ef9aa30ceea53..74505c9ec1a08cf3ffdb55bf578d40ede3cc5d00 100644 (file)
@@ -1234,12 +1234,9 @@ static irqreturn_t bme280_trigger_handler(int irq, void *p)
                s32 comp_temp;
                u32 comp_humidity;
                aligned_s64 timestamp;
-       } buffer;
+       } buffer = { }; /* Don't leak uninitialized stack to userspace. */
        int ret;
 
-       /* Don't leak uninitialized stack to userspace. */
-       memset(&buffer, 0, sizeof(buffer));
-
        guard(mutex)(&data->lock);
 
        /* Burst read data registers */