Linux ACPI
 help / color / mirror / Atom feed
From: Len Brown <lenb@kernel.org>
To: devel@acpica.org
Cc: linux-acpi@vger.kernel.org, Dan Carpenter <error27@gmail.com>
Subject: [patch] prevent possible NULL dereference. (fwd)
Date: Wed, 09 Dec 2009 14:34:56 -0500 (EST)	[thread overview]
Message-ID: <alpine.LFD.2.00.0912091433040.24891@localhost.localdomain> (raw)

forwarded to devel@acpica.org

thanks,
Len Brown, Intel Open Source Technology Center

---------- Forwarded message ----------
Date: Tue, 10 Nov 2009 11:02:49 +0200 (SAST)
From: Dan Carpenter <error27@gmail.com>
To: linux-acpi@vger.kernel.org
Cc: lenb@kernel.org
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

Signed-off-by: Dan Carpenter <error27@gmail.com>

--- 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
@@ -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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

             reply	other threads:[~2009-12-09 19:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-09 19:34 Len Brown [this message]
2009-12-09 19:54 ` [Devel] [patch] prevent possible NULL dereference. (fwd) Moore, Robert
2009-12-09 20:36   ` Len Brown
2009-12-10 22:50 ` Moore, Robert

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=alpine.LFD.2.00.0912091433040.24891@localhost.localdomain \
    --to=lenb@kernel.org \
    --cc=devel@acpica.org \
    --cc=error27@gmail.com \
    --cc=linux-acpi@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox