From nobody Sat Oct 11 04:31:32 2025 Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C95025F99B for ; Wed, 11 Jun 2025 22:42:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749681771; cv=none; b=XCj42IQn9OnugYcSzqPUreMw//vI/7SZ9sTvVo89mDO+A0f/TqoWuOGbXPYh+KO/qg0zRnxmavQUosll3LbU+VIkCLkTLKHHTVl1KiNM7/7pZ/VFNNHpPu0jgVBMdeECDWBwicQP0kYo+vn7VKsBDHhftpQXy4T6PFV+qI+khis= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749681771; c=relaxed/simple; bh=fAkKApzgvKKCY+4XB2hNM39jEFCTxF0PElDrgzvAlfA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Lp0CQQeTauVhWW66pf+VZduTAkkLkrAo4IFQjLGztMox8ru6IDrFOAkyTN7F/Ep0DNgS/3yZ1fe9xPtraPUGIZs0TVAtur7AHYS8PO4d5ZFFfrzBIu1EUUuAt8n3Sx24kEs1xFVc239tBSSAHwqwiPNt93iMxp/WOQlwRN0BUIc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=RdLgWZa2; arc=none smtp.client-ip=209.85.167.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="RdLgWZa2" Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-401f6513cb2so776395b6e.0 for ; Wed, 11 Jun 2025 15:42:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1749681768; x=1750286568; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=FaCqKPIs2f0ylRS6bTSnQ5BqgfESWCqO1Av05E42Aq8=; b=RdLgWZa2Vc34/qYNPisBXxqg82arRz0uBD/VFP1QmO+NXHVaz94nXOh2psViGhE+o1 +c3qQckjo0DPu2t2NngarfEfOPPNeIyZzFNx9EAevQfSh+Li3CFEf4LVWvsGr4X8oEy7 BZ5XvRgG6WnW1P3j2XFWve3uBlxeWkgIaheoEXfV9INODBaOXKFASYu2FP6ITeX0+2Bf 80EH93QiznRW90QCUgweceEwPf+1KklNX4IsrLa0SKuDMyO9+iDN8w3pE4wnOT/EqnCL 0Rlp6fCI5Dxd4h2m1mT/ogG2z1GqTWYnmJkj+RcqbXeuz41aeIMqMEaoIPXS5klNBdr9 TDbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749681768; x=1750286568; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FaCqKPIs2f0ylRS6bTSnQ5BqgfESWCqO1Av05E42Aq8=; b=lWJBhsHrTINq+ryqwy/ML0qSfV39tPqsUe0VQiVDvKesBIq+a1cbY/r/FG8HEi2MUA 40nR4iDbPZqv/zmqSgRxHH3BHbUlLBYTeJn93ez5h8qpu4fB8gvboePz3KWJrllTh16E HW5ik4d9XhzVa4MCQG57fduG5VAAaiI8iWKx0IFleCy05eMooNXvAS4N+1BDrSjXwwK0 Tvq0idl5hcQpRMsHgSpLQAw/cK4PERvkeM31du7xEiF5vPYCGXVB3/vPMDwIGpXAVXBU A+MqruQNfBAsS3WPNusvRzOyQc55eAKvMlTbj8opu2otsFEOJriZ+sQ2UBs0gbcB3E+3 kP1A== X-Forwarded-Encrypted: i=1; AJvYcCWaYTsj1JB33Ttu5Y6Vm7fQVYxzwbK+sF1xeqkcJdwqqzglPXVZ6ZpB1L8v2kDtr/PqD7C35UDRji92yFc=@vger.kernel.org X-Gm-Message-State: AOJu0YxP38jXTDUi5Ub57hdFizAFrq9SyTJXRY81+tNd/NnjcgQFescm d3ZVSiOgBd3TbnaX8TCc6MaAm9NHDWUns0Rc2UR+CjrjsjvQKqqVb3vfJKuKBcDPdXo= X-Gm-Gg: ASbGncsXNFMAYx5doaZ07SJYwxjuAXmEeflzz6k/Qhaez1lv6AbxUf12vNIAlU0Z8v9 daS88JO8FCiqdFdLYm5aaJ6yLu+QNmu+VoFve5PhJ37c8C4uANccr157uu3xN+OSQd96f4WWF+v ja7vYM2yWqerD7iTbsSwpwhQru64TShez2RauLQ69kKhpZiCxtMnfCbMpbYEhebTUspTFKVetO1 IYRMeBAVsOtLkYniyGyGYVqRsH8tKMZjRyJMjpS5hIgmqBpngsIN5pBTP/+qeeNkRkLdWbfpdsZ YuN9Bg+DSVefL+GOGGEv581UCPxSeINr1KDzSHrI0wV7a8UKrp3QZkfPKFz/j+paookp X-Google-Smtp-Source: AGHT+IEqBdswhJxFab3cfPWoCt/XhvSdy8p4DMoA4oBrcj8i32O67dKlBd9w/Xt2c78Lmmmu54g1yQ== X-Received: by 2002:a05:6808:3403:b0:407:a0ea:a233 with SMTP id 5614622812f47-40a66081d10mr892925b6e.10.1749681768360; Wed, 11 Jun 2025 15:42:48 -0700 (PDT) Received: from [127.0.1.1] ([2600:8803:e7e4:1d00:4753:719f:673f:547c]) by smtp.gmail.com with ESMTPSA id 5614622812f47-40a682fbf05sm24684b6e.32.2025.06.11.15.42.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jun 2025 15:42:47 -0700 (PDT) From: David Lechner Date: Wed, 11 Jun 2025 17:39:08 -0500 Subject: [PATCH 16/28] iio: imu: inv_icm42600: use = { } instead of memset() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250611-iio-zero-init-stack-with-instead-of-memset-v1-16-ebb2d0a24302@baylibre.com> References: <20250611-iio-zero-init-stack-with-instead-of-memset-v1-0-ebb2d0a24302@baylibre.com> In-Reply-To: <20250611-iio-zero-init-stack-with-instead-of-memset-v1-0-ebb2d0a24302@baylibre.com> To: Michael Hennerich , Lars-Peter Clausen , Jonathan Cameron , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Matthias Brugger , AngeloGioacchino Del Regno , Heiko Stuebner , Maxime Coquelin , Alexandre Torgue , Francesco Dolcini , =?utf-8?q?Jo=C3=A3o_Paulo_Gon=C3=A7alves?= , =?utf-8?q?Leonard_G=C3=B6hrs?= , kernel@pengutronix.de, Oleksij Rempel , Roan van Dijk , Tomasz Duszynski , Jacopo Mondi , Jean-Baptiste Maneyrol , Mudit Sharma , Javier Carrasco , =?utf-8?q?Ond=C5=99ej_Jirman?= , Andreas Klinger , Petre Rodan Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, David Lechner X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2716; i=dlechner@baylibre.com; h=from:subject:message-id; bh=fAkKApzgvKKCY+4XB2hNM39jEFCTxF0PElDrgzvAlfA=; b=owEBbQGS/pANAwAKAcLMIAH/AY/AAcsmYgBoSgXt+4nZ+zbyhmjJNdPfIxZOtXs2Bk8+N21Ob xic8BlFYmWJATMEAAEKAB0WIQTsGNmeYg6D1pzYaJjCzCAB/wGPwAUCaEoF7QAKCRDCzCAB/wGP wIUNB/48BoC8ymocKlLoNu3v5QYdcqupR0Gl4uhHgWI4Jt4Brgahbb5SfPq/3olqkbiy+T1Ookv DWyixFwL+PnlcdEYgsS3FtkBM77VlMTSo6KPDdiudRl4FOE1D8dxwHWMFTSURf17zsYwE+dDLHp YZRLNMo9fWgXqlnqEsBGDUgu2l57aaQxB6TaIlukki2lYZmsUTkPQsTN9JnX1WWTeNubNgf9d9W 0ZUaDpZW1pcDF8oQsk1+HVaB1pWPs5UwKNoW9xGgFt43NyStIN8Eb/T84MFJaOOu+ikBdQENY1a Diwzxh8L7c4dTlMajUB9DvjbZGuzAcjh6/xW+3qRtK6/KKlM X-Developer-Key: i=dlechner@baylibre.com; a=openpgp; fpr=8A73D82A6A1F509907F373881F8AF88C82F77C03 Use { } instead of memset() to zero-initialize stack memory to simplify the code. Signed-off-by: David Lechner --- 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/ii= o/imu/inv_icm42600/inv_icm42600_accel.c index e6cd9dcb0687d19554e63a69dc60f065c58d70ee..dbd315ad3c4d2bd5085f7cd3cdc= 6de4391b1c896 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 =3D { }; =20 /* parse all fifo packets */ for (i =3D 0, no =3D 0; i < st->fifo.count; i +=3D 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); =20 - /* 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 =3D 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 b4d7ce1432a4f4d096599877040a89ede0625e0b..4058eca076d8b03a2290535eedf= fa0a74098d739 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 =3D { }; =20 /* parse all fifo packets */ for (i =3D 0, no =3D 0; i < st->fifo.count; i +=3D 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); =20 - /* 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 =3D temp ? (*temp * 64) : 0; --=20 2.43.0