ACPI : Check parameter when calling acpi_processor_get/set_throttling

Previous thread: ACPI: Set _PSD ACPI_PDC_SMP_T_SWCOORD by Linux Kernel Mailing List on Thursday, February 7, 2008 - 12:02 pm. (1 message)

Next thread: ACPI : Update T-state coordination after getting _TSD info by Linux Kernel Mailing List on Thursday, February 7, 2008 - 12:02 pm. (1 message)
From: Linux Kernel Mailing List
Date: Thursday, February 7, 2008 - 12:02 pm

Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=876542...
Commit:     87654273ef63213f90c4243913987436495824f0
Parent:     3abbd337c60591305cbfeb984ff2922c175be37f
Author:     Zhao Yakui <yakui.zhao@intel.com>
AuthorDate: Mon Jan 28 13:53:30 2008 +0800
Committer:  Len Brown <len.brown@intel.com>
CommitDate: Sat Feb 2 02:29:58 2008 -0500

    ACPI : Check parameter when calling acpi_processor_get/set_throttling
    
    It is necessary to check the parameter when calling the function of
    acpi_processor_get/set_throttling function so as to avoid the NULL
    pointer reference in pr or throttling.
    
    http://bugzilla.kernel.org/show_bug.cgi?id=9747
    
    Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>
---
 drivers/acpi/processor_throttling.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 1685b40..5d2eae2 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -589,6 +589,11 @@ static int acpi_processor_get_throttling(struct acpi_processor *pr)
 	cpumask_t saved_mask;
 	int ret;
 
+	if (!pr)
+		return -EINVAL;
+
+	if (!pr->flags.throttling)
+		return -ENODEV;
 	/*
 	 * Migrate task to the cpu pointed by pr.
 	 */
@@ -743,6 +748,16 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
 {
 	cpumask_t saved_mask;
 	int ret;
+
+	if (!pr)
+		return -EINVAL;
+
+	if (!pr->flags.throttling)
+		return -ENODEV;
+
+	if ((state < 0) || (state > (pr->throttling.state_count - 1)))
+		return -EINVAL;
+
 	/*
 	 * Migrate task to the cpu pointed by pr.
 	 */
-

Previous thread: ACPI: Set _PSD ACPI_PDC_SMP_T_SWCOORD by Linux Kernel Mailing List on Thursday, February 7, 2008 - 12:02 pm. (1 message)

Next thread: ACPI : Update T-state coordination after getting _TSD info by Linux Kernel Mailing List on Thursday, February 7, 2008 - 12:02 pm. (1 message)