From: Jonathan Cameron <jic23@kernel.org>
To: Tristan Madani <tristmd@gmail.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
Kevin Tsai <ktsai@capellamicro.com>,
Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>,
David Lechner <dlechner@baylibre.com>,
Nuno Sa <nuno.sa@analog.com>, Andy Shevchenko <andy@kernel.org>,
Hans de Goede <hansg@kernel.org>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org,
Tristan Madani <tristan@talencesecurity.com>
Subject: Re: [PATCH v2 2/2] iio: imu: inv_mpu6050: validate ACPI object types in asus_acpi_get_sensor_info()
Date: Tue, 27 Oct 2026 01:07:25 +0000 [thread overview]
Message-ID: <20261027010725.4fa8ea9b@jic23-hlaptop> (raw)
In-Reply-To: <20261026142040.62383-3-tristmd@gmail.com>
On Mon, 26 Oct 2026 14:20:39 +0000
Tristan Madani <tristmd@gmail.com> wrote:
> From: Tristan Madani <tristan@talencesecurity.com>
>
> asus_acpi_get_sensor_info() iterates through a nested ACPI package
> structure without checking types at either level. The outer object
> returned by acpi_evaluate_object() and each inner element must be
> validated as ACPI_TYPE_PACKAGE before accessing their package.count
> and package.elements members.
>
> Use acpi_evaluate_object_typed() to validate the outer object type
> at evaluation time. Add a type check for each inner element before
> accessing its package contents. Also replace kfree() with
> ACPI_FREE() for the ACPI-allocated buffer.
>
> Fixes: a35c5d1aa96a ("iio: imu: inv_mpu6050: Create mux clients for ACPI")
> Cc: stable@vger.kernel.org
> Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
> ---
> drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
> index 460792ed27e031..e5ffa0d5f6b1a2 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
> @@ -52,7 +52,8 @@ static int asus_acpi_get_sensor_info(struct acpi_device *adev,
> union acpi_object *cpm;
> int ret;
>
> - status = acpi_evaluate_object(adev->handle, "CNF0", NULL, &buffer);
> + status = acpi_evaluate_object_typed(adev->handle, "CNF0", NULL,
> + &buffer, ACPI_TYPE_PACKAGE);
Same as previous wrt to indent. In the kernel style guide
this is only there implicitly in examples, but it is definitely
preferred choice for IIO and I don't recall seeing anywhere in
the kernel where this wasn't an acceptable choice.
Jonathan
> if (ACPI_FAILURE(status))
> return -ENODEV;
>
> @@ -62,6 +63,8 @@ static int asus_acpi_get_sensor_info(struct acpi_device *adev,
> int j;
>
> elem = &cpm->package.elements[i];
> + if (elem->type != ACPI_TYPE_PACKAGE)
> + continue;
> for (j = 0; j < elem->package.count; ++j) {
> union acpi_object *sub_elem;
>
> @@ -78,7 +81,7 @@ static int asus_acpi_get_sensor_info(struct acpi_device *adev,
> }
> }
> ret = cpm->package.count;
> - kfree(buffer.pointer);
> + ACPI_FREE(buffer.pointer);
>
> return ret;
> }
next prev parent reply other threads:[~2026-10-27 1:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-26 14:20 [PATCH v2 0/2] iio: validate ACPI object types before package access Tristan Madani
2026-10-26 14:20 ` [PATCH v2 1/2] iio: light: cm32181: validate ACPI object type in cm32181_acpi_get_cpm() Tristan Madani
2026-10-27 1:04 ` Jonathan Cameron
2026-10-26 14:20 ` [PATCH v2 2/2] iio: imu: inv_mpu6050: validate ACPI object types in asus_acpi_get_sensor_info() Tristan Madani
2026-10-27 1:07 ` Jonathan Cameron [this message]
2026-10-29 11:08 ` [PATCH v3 0/2] iio: validate ACPI return types in sensor drivers Tristan Madani
2026-10-29 11:08 ` [PATCH v3 1/2] iio: light: cm32181: validate ACPI object type in cm32181_acpi_get_cpm() Tristan Madani
2026-10-29 11:08 ` [PATCH v3 2/2] iio: imu: inv_mpu6050: validate ACPI object types in asus_acpi_get_sensor_info() Tristan Madani
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261027010725.4fa8ea9b@jic23-hlaptop \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=hansg@kernel.org \
--cc=jean-baptiste.maneyrol@tdk.com \
--cc=ktsai@capellamicro.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=stable@vger.kernel.org \
--cc=tristan@talencesecurity.com \
--cc=tristmd@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.