Skip to contentSkip to conversation

prevent possible NULL dereference. (fwd)

PATCH In review Len Brown 2 participants 4 messages Dec 9, 2009 – Dec 10, 2009

Subsystems (2)
lore
Share & tools
lore

Len Brown

author
#0 lore raw

PATCH 1/1 prevent possible NULL dereference. (fwd)

forwarded to [email protected]

thanks,
Len Brown, Intel Open Source Technology Center

---------- Forwarded message ----------
Date: Tue, 10 Nov 2009 11:02:49 +0200 (SAST)
From: Dan Carpenter <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: [patch] prevent possible NULL dereference.

Move the check for walk_state->thread before the dereference.

Found by smatch static checker. Compile tested.

regards,
dan carpenter

drivers/acpi/acpica/exmutex.c +9 -9
@@ -375,6 +375,15 @@
 		return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED);
 	}
 
+	/* Must have a valid thread ID */
+
+	if (!walk_state->thread) {
+		ACPI_ERROR((AE_INFO,
+			    "Cannot release Mutex [%4.4s], null thread info",
+			    acpi_ut_get_node_name(obj_desc->mutex.node)));
+		return_ACPI_STATUS(AE_AML_INTERNAL);
+	}
+
 	/*
 	 * The Mutex is owned, but this thread must be the owner.
 	 * Special case for Global Lock, any thread can release
@@ -392,15 +401,6 @@
 		return_ACPI_STATUS(AE_AML_NOT_OWNER);
 	}
 
-	/* Must have a valid thread ID */
-
-	if (!walk_state->thread) {
-		ACPI_ERROR((AE_INFO,
-			    "Cannot release Mutex [%4.4s], null thread info",
-			    acpi_ut_get_node_name(obj_desc->mutex.node)));
-		return_ACPI_STATUS(AE_AML_INTERNAL);
-	}
-
 	/*
 	 * The sync level of the mutex must be equal to the current sync level. In
 	 * other words, the current level means that at least one mutex at that

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#1 lore raw

Was this in response to a specific problem seen in the field? Bob

Quoted 75 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Len Brown
Sent: Wednesday, December 09, 2009 11:35 AM
To: [email protected]
Cc: [email protected]; Dan Carpenter
Subject: [Devel] [patch] prevent possible NULL dereference. (fwd)

forwarded to [email protected]

thanks,
Len Brown, Intel Open Source Technology Center

---------- Forwarded message ----------
Date: Tue, 10 Nov 2009 11:02:49 +0200 (SAST)
From: Dan Carpenter <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: [patch] prevent possible NULL dereference.

Move the check for walk_state->thread before the dereference.

Found by smatch static checker. Compile tested.

regards,
dan carpenter

--- orig/drivers/acpi/acpica/exmutex.c 2009-11-07 09:46:53.000000000
+0200
+++ devel/drivers/acpi/acpica/exmutex.c 2009-11-07 09:48:16.000000000
+0200

drivers/acpi/acpica/exmutex.c +9 -9
@@ -375,6 +375,15 @@
 		return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED);
 	}
 
+	/* Must have a valid thread ID */
+
+	if (!walk_state->thread) {
+		ACPI_ERROR((AE_INFO,
+			    "Cannot release Mutex [%4.4s], null thread info",
+			    acpi_ut_get_node_name(obj_desc->mutex.node)));
+		return_ACPI_STATUS(AE_AML_INTERNAL);
+	}
+
 	/*
 	 * The Mutex is owned, but this thread must be the owner.
 	 * Special case for Global Lock, any thread can release
@@ -392,15 +401,6 @@
 		return_ACPI_STATUS(AE_AML_NOT_OWNER);
 	}
 
-	/* Must have a valid thread ID */
-
-	if (!walk_state->thread) {
-		ACPI_ERROR((AE_INFO,
-			    "Cannot release Mutex [%4.4s], null thread info",
-			    acpi_ut_get_node_name(obj_desc->mutex.node)));
-		return_ACPI_STATUS(AE_AML_INTERNAL);
-	}
-
 	/*
 	 * The sync level of the mutex must be equal to the current sync

level. In
* other words, the current level means that at least one mutex at
that
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
_______________________________________________
Devel mailing list
[email protected]
http://lists.acpica.org/listinfo/devel

author
#2 lore raw
Quoted 1 line

Was this in response to a specific problem seen in the field?

I don't think so, the submitter refers to a static code checker -- simply identifying a use before test.

-Len

Quoted 81 lines
Quoted 68 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Len Brown
Sent: Wednesday, December 09, 2009 11:35 AM
To: [email protected]
Cc: [email protected]; Dan Carpenter
Subject: [Devel] [patch] prevent possible NULL dereference. (fwd)

forwarded to [email protected]

thanks,
Len Brown, Intel Open Source Technology Center

---------- Forwarded message ----------
Date: Tue, 10 Nov 2009 11:02:49 +0200 (SAST)
From: Dan Carpenter <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: [patch] prevent possible NULL dereference.

Move the check for walk_state->thread before the dereference.

Found by smatch static checker. Compile tested.

regards,
dan carpenter

--- orig/drivers/acpi/acpica/exmutex.c 2009-11-07 09:46:53.000000000
+0200
+++ devel/drivers/acpi/acpica/exmutex.c 2009-11-07 09:48:16.000000000
+0200

drivers/acpi/acpica/exmutex.c +9 -9
@@ -375,6 +375,15 @@
 		return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED);
 	}
 
+	/* Must have a valid thread ID */
+
+	if (!walk_state->thread) {
+		ACPI_ERROR((AE_INFO,
+			    "Cannot release Mutex [%4.4s], null thread info",
+			    acpi_ut_get_node_name(obj_desc->mutex.node)));
+		return_ACPI_STATUS(AE_AML_INTERNAL);
+	}
+
 	/*
 	 * The Mutex is owned, but this thread must be the owner.
 	 * Special case for Global Lock, any thread can release
@@ -392,15 +401,6 @@
 		return_ACPI_STATUS(AE_AML_NOT_OWNER);
 	}
 
-	/* Must have a valid thread ID */
-
-	if (!walk_state->thread) {
-		ACPI_ERROR((AE_INFO,
-			    "Cannot release Mutex [%4.4s], null thread info",
-			    acpi_ut_get_node_name(obj_desc->mutex.node)));
-		return_ACPI_STATUS(AE_AML_INTERNAL);
-	}
-
 	/*
 	 * The sync level of the mutex must be equal to the current sync

level. In
* other words, the current level means that at least one mutex at
that

Quoted 8 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
_______________________________________________
Devel mailing list
[email protected]
http://lists.acpica.org/listinfo/devel

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
In reply to Len Brown

Added to ACPICA base code for the next release (mid-December).

Thanks,
Bob

Quoted 75 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Len Brown
Sent: Wednesday, December 09, 2009 11:35 AM
To: [email protected]
Cc: [email protected]; Dan Carpenter
Subject: [Devel] [patch] prevent possible NULL dereference. (fwd)

forwarded to [email protected]

thanks,
Len Brown, Intel Open Source Technology Center

---------- Forwarded message ----------
Date: Tue, 10 Nov 2009 11:02:49 +0200 (SAST)
From: Dan Carpenter <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: [patch] prevent possible NULL dereference.

Move the check for walk_state->thread before the dereference.

Found by smatch static checker. Compile tested.

regards,
dan carpenter

--- orig/drivers/acpi/acpica/exmutex.c 2009-11-07 09:46:53.000000000
+0200
+++ devel/drivers/acpi/acpica/exmutex.c 2009-11-07 09:48:16.000000000
+0200

drivers/acpi/acpica/exmutex.c +9 -9
@@ -375,6 +375,15 @@
 		return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED);
 	}
 
+	/* Must have a valid thread ID */
+
+	if (!walk_state->thread) {
+		ACPI_ERROR((AE_INFO,
+			    "Cannot release Mutex [%4.4s], null thread info",
+			    acpi_ut_get_node_name(obj_desc->mutex.node)));
+		return_ACPI_STATUS(AE_AML_INTERNAL);
+	}
+
 	/*
 	 * The Mutex is owned, but this thread must be the owner.
 	 * Special case for Global Lock, any thread can release
@@ -392,15 +401,6 @@
 		return_ACPI_STATUS(AE_AML_NOT_OWNER);
 	}
 
-	/* Must have a valid thread ID */
-
-	if (!walk_state->thread) {
-		ACPI_ERROR((AE_INFO,
-			    "Cannot release Mutex [%4.4s], null thread info",
-			    acpi_ut_get_node_name(obj_desc->mutex.node)));
-		return_ACPI_STATUS(AE_AML_INTERNAL);
-	}
-
 	/*
 	 * The sync level of the mutex must be equal to the current sync

level. In
* other words, the current level means that at least one mutex at
that
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
_______________________________________________
Devel mailing list
[email protected]
http://lists.acpica.org/listinfo/devel