linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Felipe Alfaro Solana <felipe_alfaro@linuxmail.org>
To: acpi-devel@lists.sourceforge.net
Cc: Linux Kernel Mailinglist <linux-kernel@vger.kernel.org>
Subject: [RFC] enhanced psxface.c error handling
Date: Thu, 04 Dec 2003 17:02:33 +0100	[thread overview]
Message-ID: <1070553752.14488.4.camel@glass.felipe-alfaro.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 168 bytes --]

Hi!

This patch tries to fix the situation where an error could cause
acpi_psx_execute() to exit without releasing held references to the
elements of param[].

Thanks!

[-- Attachment #2: acpi.patch --]
[-- Type: text/x-patch, Size: 2599 bytes --]

diff -uNr linux-2.6.0-test11.orig/drivers/acpi/parser/psxface.c linux-2.6.0-test11/drivers/acpi/parser/psxface.c
--- linux-2.6.0-test11.orig/drivers/acpi/parser/psxface.c	2003-11-26 21:45:20.000000000 +0100
+++ linux-2.6.0-test11/drivers/acpi/parser/psxface.c	2003-12-01 09:23:18.591462114 +0100
@@ -127,7 +127,8 @@
 
 	op = acpi_ps_create_scope_op ();
 	if (!op) {
-		return_ACPI_STATUS (AE_NO_MEMORY);
+		status = AE_NO_MEMORY;
+		goto acpi_psx_parse_unref;
 	}
 
 	/*
@@ -142,14 +143,15 @@
 	walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id,
 			   NULL, NULL, NULL);
 	if (!walk_state) {
-		return_ACPI_STATUS (AE_NO_MEMORY);
+		goto acpi_psx_parse_unref;
+		status = AE_NO_MEMORY;
 	}
 
 	status = acpi_ds_init_aml_walk (walk_state, op, method_node, obj_desc->method.aml_start,
 			  obj_desc->method.aml_length, NULL, NULL, 1);
 	if (ACPI_FAILURE (status)) {
 		acpi_ds_delete_walk_state (walk_state);
-		return_ACPI_STATUS (status);
+		goto acpi_psx_parse_unref;
 	}
 
 	/* Parse the AML */
@@ -168,7 +170,8 @@
 
 	op = acpi_ps_create_scope_op ();
 	if (!op) {
-		return_ACPI_STATUS (AE_NO_MEMORY);
+		status = AE_NO_MEMORY;
+		goto acpi_psx_parse_unref;
 	}
 
 	/* Init new op with the method name and pointer back to the NS node */
@@ -180,14 +183,15 @@
 
 	walk_state = acpi_ds_create_walk_state (0, NULL, NULL, NULL);
 	if (!walk_state) {
-		return_ACPI_STATUS (AE_NO_MEMORY);
+		status = AE_NO_MEMORY;
+		goto acpi_psx_parse_unref;
 	}
 
 	status = acpi_ds_init_aml_walk (walk_state, op, method_node, obj_desc->method.aml_start,
 			  obj_desc->method.aml_length, params, return_obj_desc, 3);
 	if (ACPI_FAILURE (status)) {
 		acpi_ds_delete_walk_state (walk_state);
-		return_ACPI_STATUS (status);
+		goto acpi_psx_parse_unref;
 	}
 
 	/*
@@ -196,16 +200,6 @@
 	status = acpi_ps_parse_aml (walk_state);
 	acpi_ps_delete_parse_tree (op);
 
-	if (params) {
-		/* Take away the extra reference that we gave the parameters above */
-
-		for (i = 0; params[i]; i++) {
-			/* Ignore errors, just do them all */
-
-			(void) acpi_ut_update_object_reference (params[i], REF_DECREMENT);
-		}
-	}
-
 	/*
 	 * If the method has returned an object, signal this to the caller with
 	 * a control exception code
@@ -218,6 +212,18 @@
 		status = AE_CTRL_RETURN_VALUE;
 	}
 
+acpi_psx_parse_unref:
+
+	if (params) {
+		/* Take away the extra reference that we gave the parameters above */
+
+		for (i = 0; params[i]; i++) {
+			/* Ignore errors, just do them all */
+
+			(void) acpi_ut_update_object_reference (params[i], REF_DECREMENT);
+		}
+	}
+
 	return_ACPI_STATUS (status);
 }

             reply	other threads:[~2003-12-04 16:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-04 16:02 Felipe Alfaro Solana [this message]
2003-12-04 16:14 ` [RFC] enhanced psxface.c error handling Mihai RUSU
2003-12-04 22:00   ` Felipe Alfaro Solana

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=1070553752.14488.4.camel@glass.felipe-alfaro.com \
    --to=felipe_alfaro@linuxmail.org \
    --cc=acpi-devel@lists.sourceforge.net \
    --cc=linux-kernel@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;
as well as URLs for NNTP newsgroup(s).