Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5613A63CF for ; Sun, 24 Aug 2025 13:01:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756040499; cv=none; b=dO5GJ869MmeSRzwG1hnUECP/HCJHRPBmcWXUxiCaUd1S32rd24iaxLIq13Tc5mDxB2MjrwNeZWl3AY0TcdPnGqKIG+ahQWL+MJvX8a8KbN0KQEsOLpoMw1YEE47gI+IC1MLNphG8arVpDfwdgzkoKA3uBwcx2rdmm13mv2bb3hc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756040499; c=relaxed/simple; bh=uDSudNxOFN9qQY9rHEbeE3aOJI1Q2/MI/LCtMY+oCIk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ISa2t/4gmAMAPFwb6NG1MjfOdwDeRIEi6X2Gx7wrxbdvZ9irAUVAcIFjug0Zjsa+BGac9/F0jNeJOk4JXtHiQp9yZRHzZU9P8t7RhATJ3YPFIg9sU7I4VGs58NhoFew3crD+LfPO7xVDqMnX9ZSHqJcpUaW0y9iRrybl2OTN+V4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XD0um4/T; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XD0um4/T" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3CF00C4CEEB; Sun, 24 Aug 2025 13:01:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1756040498; bh=uDSudNxOFN9qQY9rHEbeE3aOJI1Q2/MI/LCtMY+oCIk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XD0um4/TeUCOZCHaGQpOwqS0rIrOUJpq6SyNWKQ5fgCVOz5VGtMeh2e0+hhTYYyCJ 18kqqCNm8QFdMZezLfRT6GfxA2truX+c+9hAZq8P9UgLG7eq2+C0Qjp64eaILzVHji 5BA6RE3YocX/UHqfoIw6a+OkvHqtzx0HXyAE2A4JXjzuo/FyKj5X1Ahv5AwWtUjZf7 IqbPzqOdDLfaZB1BSBk7hRDogyJYF9Hz0dF5TNXjEwFqH/9poY/U+bTuLyB44/pVXv uEXZSMIvtvO28p1BQ3R+WSY1acvZtI2kRQRL8u3bEITSX0m7y8D0TWin8y+eB6siku wBSmiEfP4ndlw== From: Sasha Levin To: stable@vger.kernel.org Cc: David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Jonathan Cameron , Sasha Levin Subject: [PATCH 6.16.y 1/3] iio: imu: inv_icm42600: use = { } instead of memset() Date: Sun, 24 Aug 2025 09:01:34 -0400 Message-ID: <20250824130136.2747952-1-sashal@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <2025082313-case-filtrate-5d55@gregkh> References: <2025082313-case-filtrate-5d55@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: David Lechner [ Upstream commit 352112e2d9aab6a156c2803ae14eb89a9fd93b7d ] Use { } instead of memset() to zero-initialize stack memory to simplify the code. Signed-off-by: David Lechner Reviewed-by: Nuno Sá Reviewed-by: Andy Shevchenko Link: https://patch.msgid.link/20250611-iio-zero-init-stack-with-instead-of-memset-v1-16-ebb2d0a24302@baylibre.com Signed-off-by: Jonathan Cameron Stable-dep-of: dfdc31e7ccf3 ("iio: imu: inv_icm42600: change invalid data error to -EBUSY") Signed-off-by: Sasha Levin --- drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c | 5 ++--- drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c index e6cd9dcb0687..dbd315ad3c4d 100644 --- a/drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c +++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c @@ -902,7 +902,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) { @@ -921,8 +922,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; diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c index b4d7ce1432a4..4058eca076d8 100644 --- a/drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c +++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c @@ -806,7 +806,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) { @@ -825,8 +826,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; -- 2.50.1