linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: inv_mpu6050: Fix use-after-free in ACPI code
@ 2016-06-03 18:30 Crestez Dan Leonard
  2016-06-06 12:33 ` Daniel Baluta
  0 siblings, 1 reply; 3+ messages in thread
From: Crestez Dan Leonard @ 2016-06-03 18:30 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: linux-kernel, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Daniel Baluta, Crestez Dan Leonard,
	Srinivas Pandruvada

In some cases this can result in incorrectly returning a negative value
from asus_acpi_get_sensor_info and the AK8963 magnetometer failing to
show up.

Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Crestez Dan Leonard <leonard.crestez@intel.com>
---
 drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c | 5 +++--
 1 file changed, 3 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 2771106..f770472 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
@@ -56,6 +56,7 @@ static int asus_acpi_get_sensor_info(struct acpi_device *adev,
 	int i;
 	acpi_status status;
 	union acpi_object *cpm;
+	int ret;
 
 	status = acpi_evaluate_object(adev->handle, "CNF0", NULL, &buffer);
 	if (ACPI_FAILURE(status))
@@ -82,10 +83,10 @@ static int asus_acpi_get_sensor_info(struct acpi_device *adev,
 			}
 		}
 	}
-
+	ret = cpm->package.count;
 	kfree(buffer.pointer);
 
-	return cpm->package.count;
+	return ret;
 }
 
 static int acpi_i2c_check_resource(struct acpi_resource *ares, void *data)
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio: inv_mpu6050: Fix use-after-free in ACPI code
  2016-06-03 18:30 [PATCH] iio: inv_mpu6050: Fix use-after-free in ACPI code Crestez Dan Leonard
@ 2016-06-06 12:33 ` Daniel Baluta
  2016-06-11 16:21   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Baluta @ 2016-06-06 12:33 UTC (permalink / raw)
  To: Crestez Dan Leonard
  Cc: Jonathan Cameron, linux-iio, Linux Kernel Mailing List,
	Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Daniel Baluta, Srinivas Pandruvada

On Fri, Jun 3, 2016 at 9:30 PM, Crestez Dan Leonard
<leonard.crestez@intel.com> wrote:
> In some cases this can result in incorrectly returning a negative value
> from asus_acpi_get_sensor_info and the AK8963 magnetometer failing to
> show up.
>
> Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> Signed-off-by: Crestez Dan Leonard <leonard.crestez@intel.com>

Looks good to me. I had to look into the code to see that
cpm is an alias for buffer.pointer, perhaps this should have been
mentioned in the commit message.

Acked-by: Daniel Baluta <daniel.baluta@intel.com>

> ---
>  drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c | 5 +++--
>  1 file changed, 3 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 2771106..f770472 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
> @@ -56,6 +56,7 @@ static int asus_acpi_get_sensor_info(struct acpi_device *adev,
>         int i;
>         acpi_status status;
>         union acpi_object *cpm;
> +       int ret;
>
>         status = acpi_evaluate_object(adev->handle, "CNF0", NULL, &buffer);
>         if (ACPI_FAILURE(status))
> @@ -82,10 +83,10 @@ static int asus_acpi_get_sensor_info(struct acpi_device *adev,
>                         }
>                 }
>         }
> -
> +       ret = cpm->package.count;
>         kfree(buffer.pointer);
>
> -       return cpm->package.count;
> +       return ret;
>  }
>
>  static int acpi_i2c_check_resource(struct acpi_resource *ares, void *data)
> --
> 2.5.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio: inv_mpu6050: Fix use-after-free in ACPI code
  2016-06-06 12:33 ` Daniel Baluta
@ 2016-06-11 16:21   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2016-06-11 16:21 UTC (permalink / raw)
  To: Daniel Baluta, Crestez Dan Leonard
  Cc: linux-iio, Linux Kernel Mailing List, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, Srinivas Pandruvada

On 06/06/16 13:33, Daniel Baluta wrote:
> On Fri, Jun 3, 2016 at 9:30 PM, Crestez Dan Leonard
> <leonard.crestez@intel.com> wrote:
>> In some cases this can result in incorrectly returning a negative value
>> from asus_acpi_get_sensor_info and the AK8963 magnetometer failing to
>> show up.
>>
>> Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
>> Signed-off-by: Crestez Dan Leonard <leonard.crestez@intel.com>
> 
> Looks good to me. I had to look into the code to see that
> cpm is an alias for buffer.pointer, perhaps this should have been
> mentioned in the commit message.
> 
> Acked-by: Daniel Baluta <daniel.baluta@intel.com>
I added a note on that to the commit message and applied to the fixes-togreg
branch of iio.git.

Thanks,

Jonathan
> 
>> ---
>>  drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c | 5 +++--
>>  1 file changed, 3 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 2771106..f770472 100644
>> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
>> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
>> @@ -56,6 +56,7 @@ static int asus_acpi_get_sensor_info(struct acpi_device *adev,
>>         int i;
>>         acpi_status status;
>>         union acpi_object *cpm;
>> +       int ret;
>>
>>         status = acpi_evaluate_object(adev->handle, "CNF0", NULL, &buffer);
>>         if (ACPI_FAILURE(status))
>> @@ -82,10 +83,10 @@ static int asus_acpi_get_sensor_info(struct acpi_device *adev,
>>                         }
>>                 }
>>         }
>> -
>> +       ret = cpm->package.count;
>>         kfree(buffer.pointer);
>>
>> -       return cpm->package.count;
>> +       return ret;
>>  }
>>
>>  static int acpi_i2c_check_resource(struct acpi_resource *ares, void *data)
>> --
>> 2.5.5
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-06-11 16:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-03 18:30 [PATCH] iio: inv_mpu6050: Fix use-after-free in ACPI code Crestez Dan Leonard
2016-06-06 12:33 ` Daniel Baluta
2016-06-11 16:21   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).