lkml.org 
[lkml]   [2003]   [Dec]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[RFC] enhanced psxface.c error handling
From
Date
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!
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);
}
\
 
 \ /
  Last update: 2005-03-22 13:59    [from the cache]
©2003-2011 Jasper Spaans