From mboxrd@z Thu Jan 1 00:00:00 1970 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 C9DE12FB084 for ; Mon, 20 Oct 2025 13:09:43 +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=1760965783; cv=none; b=pNaFR8LxiEdEJHYJgS75RdjXQykaSBLgCogt0TUZEFXZpmBJXH3PP5fkzhw87OfYxPhpN6GgkUMg6iOagKwmNwfQpfF8Ml/s9cHykpni8b19elZtrF21/PjBRgtdVSmnXLC34aoh+i23yn5y/ZiWT6nPgIKStjq7m9ezaAiMINw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760965783; c=relaxed/simple; bh=ZrADtkXYvPAaOW+eUqadCCJQMVbpmaj2I7irxpdlrRo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YsbP/bNUWTqf+oJUbBc1V80/f89Dd9Xp9SznD6QPGNE1sMOyrn0H/8qQeQXI1HCsSDPWHBySUiaxEsWjIqMZzsYgC1GyI1a+KCr4tShpQz+s7ZJQEud7X881v5W8r7C0+YABLn/6mc7qyojSJ4QJGq5xgnWVpHjUa2Fj08bMH3M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=I8AP8xSf; 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="I8AP8xSf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7467CC113D0; Mon, 20 Oct 2025 13:09:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760965783; bh=ZrADtkXYvPAaOW+eUqadCCJQMVbpmaj2I7irxpdlrRo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I8AP8xSfogE/fe6EAFEQzMkwf3FUOVc0TJcBmcTTctKgbWTHstaowHuwn41k2jwnz pg+TmYZW+9QOeBOuqrDQGNMHdRS+RBs2f6hH2Xp4lPu5m9q48+bEl2RBnuvFkg0wT6 X4aVmuWklUQWeXIZ71nIK6xUDVBRMjLD7lMb2462GGS48Qjkpw9qMRiy0pX95A2WrK ZU/INZkBq9AHn4ZremI8mAXei10QkgUQSimh+jp+GaX9KVDo3UHlSFraLX0KoMkv7S leoMzGz0naSjfiJznthmhOArf9EXvWyQUrByOQ6bkzQesKbpovPaTQ/uep/tRQM+sJ +oCfOX8Kwy6xQ== 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.1.y 1/2] iio: imu: inv_icm42600: use = { } instead of memset() Date: Mon, 20 Oct 2025 09:09:39 -0400 Message-ID: <20251020130940.1767272-1-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <2025101623-clarify-manhood-adaa@gregkh> References: <2025101623-clarify-manhood-adaa@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: 466f7a2fef2a ("iio: imu: inv_icm42600: Avoid configuring if already pm_runtime suspended") 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 7a0f5cfd9417f..06ff9c2db04af 100644 --- a/drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c +++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c @@ -748,7 +748,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) { @@ -767,8 +768,6 @@ int inv_icm42600_accel_parse_fifo(struct iio_dev *indio_dev) inv_icm42600_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 4fb796e11486f..aad8899ef8737 100644 --- a/drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c +++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c @@ -760,7 +760,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) { @@ -779,8 +780,6 @@ int inv_icm42600_gyro_parse_fifo(struct iio_dev *indio_dev) inv_icm42600_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.51.0