aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/executer
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/executer')
-rw-r--r--drivers/acpi/executer/exconfig.c29
-rw-r--r--drivers/acpi/executer/exconvrt.c2
-rw-r--r--drivers/acpi/executer/exdump.c189
-rw-r--r--drivers/acpi/executer/exfield.c5
-rw-r--r--drivers/acpi/executer/exmisc.c2
-rw-r--r--drivers/acpi/executer/exnames.c7
-rw-r--r--drivers/acpi/executer/exoparg1.c29
-rw-r--r--drivers/acpi/executer/exoparg3.c63
-rw-r--r--drivers/acpi/executer/exresop.c16
-rw-r--r--drivers/acpi/executer/exstore.c6
-rw-r--r--drivers/acpi/executer/exstoren.c4
-rw-r--r--drivers/acpi/executer/exutils.c2
12 files changed, 266 insertions, 88 deletions
diff --git a/drivers/acpi/executer/exconfig.c b/drivers/acpi/executer/exconfig.c
index 734b2f24af48..76c6ebd0231f 100644
--- a/drivers/acpi/executer/exconfig.c
+++ b/drivers/acpi/executer/exconfig.c
@@ -376,16 +376,22 @@ acpi_ex_load_op (
376 */ 376 */
377 status = acpi_ex_read_data_from_field (walk_state, obj_desc, &buffer_desc); 377 status = acpi_ex_read_data_from_field (walk_state, obj_desc, &buffer_desc);
378 if (ACPI_FAILURE (status)) { 378 if (ACPI_FAILURE (status)) {
379 goto cleanup; 379 return_ACPI_STATUS (status);
380 } 380 }
381 381
382 table_ptr = ACPI_CAST_PTR (struct acpi_table_header, 382 table_ptr = ACPI_CAST_PTR (struct acpi_table_header,
383 buffer_desc->buffer.pointer); 383 buffer_desc->buffer.pointer);
384 384
385 /* Sanity check the table length */ 385 /* All done with the buffer_desc, delete it */
386
387 buffer_desc->buffer.pointer = NULL;
388 acpi_ut_remove_reference (buffer_desc);
389
390 /* Sanity check the table length */
386 391
387 if (table_ptr->length < sizeof (struct acpi_table_header)) { 392 if (table_ptr->length < sizeof (struct acpi_table_header)) {
388 return_ACPI_STATUS (AE_BAD_HEADER); 393 status = AE_BAD_HEADER;
394 goto cleanup;
389 } 395 }
390 break; 396 break;
391 397
@@ -413,7 +419,9 @@ acpi_ex_load_op (
413 419
414 status = acpi_ex_add_table (table_ptr, acpi_gbl_root_node, &ddb_handle); 420 status = acpi_ex_add_table (table_ptr, acpi_gbl_root_node, &ddb_handle);
415 if (ACPI_FAILURE (status)) { 421 if (ACPI_FAILURE (status)) {
416 goto cleanup; 422 /* On error, table_ptr was deallocated above */
423
424 return_ACPI_STATUS (status);
417 } 425 }
418 426
419 /* Store the ddb_handle into the Target operand */ 427 /* Store the ddb_handle into the Target operand */
@@ -421,17 +429,14 @@ acpi_ex_load_op (
421 status = acpi_ex_store (ddb_handle, target, walk_state); 429 status = acpi_ex_store (ddb_handle, target, walk_state);
422 if (ACPI_FAILURE (status)) { 430 if (ACPI_FAILURE (status)) {
423 (void) acpi_ex_unload_table (ddb_handle); 431 (void) acpi_ex_unload_table (ddb_handle);
424 }
425 432
426 return_ACPI_STATUS (status); 433 /* table_ptr was deallocated above */
427 434
435 return_ACPI_STATUS (status);
436 }
428 437
429cleanup: 438cleanup:
430 439 if (ACPI_FAILURE (status)) {
431 if (buffer_desc) {
432 acpi_ut_remove_reference (buffer_desc);
433 }
434 else {
435 ACPI_MEM_FREE (table_ptr); 440 ACPI_MEM_FREE (table_ptr);
436 } 441 }
437 return_ACPI_STATUS (status); 442 return_ACPI_STATUS (status);
@@ -482,7 +487,7 @@ acpi_ex_unload_table (
482 * Delete the entire namespace under this table Node 487 * Delete the entire namespace under this table Node
483 * (Offset contains the table_id) 488 * (Offset contains the table_id)
484 */ 489 */
485 acpi_ns_delete_namespace_by_owner (table_info->table_id); 490 acpi_ns_delete_namespace_by_owner (table_info->owner_id);
486 491
487 /* Delete the table itself */ 492 /* Delete the table itself */
488 493
diff --git a/drivers/acpi/executer/exconvrt.c b/drivers/acpi/executer/exconvrt.c
index 97856c48bd74..21331625e66e 100644
--- a/drivers/acpi/executer/exconvrt.c
+++ b/drivers/acpi/executer/exconvrt.c
@@ -367,7 +367,7 @@ acpi_ex_convert_to_ascii (
367 367
368 /* hex_length: 2 ascii hex chars per data byte */ 368 /* hex_length: 2 ascii hex chars per data byte */
369 369
370 hex_length = ACPI_MUL_2 (data_width); 370 hex_length = (acpi_native_uint) ACPI_MUL_2 (data_width);
371 for (i = 0, j = (hex_length-1); i < hex_length; i++, j--) { 371 for (i = 0, j = (hex_length-1); i < hex_length; i++, j--) {
372 /* Get one hex digit, most significant digits first */ 372 /* Get one hex digit, most significant digits first */
373 373
diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c
index 408500648114..fd13cc3db018 100644
--- a/drivers/acpi/executer/exdump.c
+++ b/drivers/acpi/executer/exdump.c
@@ -51,6 +51,11 @@
51#define _COMPONENT ACPI_EXECUTER 51#define _COMPONENT ACPI_EXECUTER
52 ACPI_MODULE_NAME ("exdump") 52 ACPI_MODULE_NAME ("exdump")
53 53
54/*
55 * The following routines are used for debug output only
56 */
57#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
58
54/* Local prototypes */ 59/* Local prototypes */
55 60
56#ifdef ACPI_FUTURE_USAGE 61#ifdef ACPI_FUTURE_USAGE
@@ -73,13 +78,17 @@ static void
73acpi_ex_out_address ( 78acpi_ex_out_address (
74 char *title, 79 char *title,
75 acpi_physical_address value); 80 acpi_physical_address value);
76#endif /* ACPI_FUTURE_USAGE */
77 81
82static void
83acpi_ex_dump_reference (
84 union acpi_operand_object *obj_desc);
78 85
79/* 86static void
80 * The following routines are used for debug output only 87acpi_ex_dump_package (
81 */ 88 union acpi_operand_object *obj_desc,
82#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 89 u32 level,
90 u32 index);
91#endif /* ACPI_FUTURE_USAGE */
83 92
84/******************************************************************************* 93/*******************************************************************************
85 * 94 *
@@ -118,7 +127,7 @@ acpi_ex_dump_operand (
118 } 127 }
119 128
120 if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) { 129 if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) {
121 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p is a NS Node: ", obj_desc)); 130 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p Namespace Node: ", obj_desc));
122 ACPI_DUMP_ENTRY (obj_desc, ACPI_LV_EXEC); 131 ACPI_DUMP_ENTRY (obj_desc, ACPI_LV_EXEC);
123 return; 132 return;
124 } 133 }
@@ -467,7 +476,7 @@ acpi_ex_dump_operands (
467 } 476 }
468 477
469 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 478 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
470 "************* Stack dump from %s(%d), %s\n", 479 "************* Operand Stack dump from %s(%d), %s\n",
471 module_name, line_number, note)); 480 module_name, line_number, note));
472 return; 481 return;
473} 482}
@@ -508,7 +517,7 @@ acpi_ex_out_integer (
508 char *title, 517 char *title,
509 u32 value) 518 u32 value)
510{ 519{
511 acpi_os_printf ("%20s : %X\n", title, value); 520 acpi_os_printf ("%20s : %.2X\n", title, value);
512} 521}
513 522
514static void 523static void
@@ -565,9 +574,144 @@ acpi_ex_dump_node (
565 574
566/******************************************************************************* 575/*******************************************************************************
567 * 576 *
577 * FUNCTION: acpi_ex_dump_reference
578 *
579 * PARAMETERS: Object - Descriptor to dump
580 *
581 * DESCRIPTION: Dumps a reference object
582 *
583 ******************************************************************************/
584
585static void
586acpi_ex_dump_reference (
587 union acpi_operand_object *obj_desc)
588{
589 struct acpi_buffer ret_buf;
590 acpi_status status;
591
592
593 if (obj_desc->reference.opcode == AML_INT_NAMEPATH_OP) {
594 acpi_os_printf ("Named Object %p ", obj_desc->reference.node);
595 ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER;
596 status = acpi_ns_handle_to_pathname (obj_desc->reference.node, &ret_buf);
597 if (ACPI_FAILURE (status)) {
598 acpi_os_printf ("Could not convert name to pathname\n");
599 }
600 else {
601 acpi_os_printf ("%s\n", ret_buf.pointer);
602 ACPI_MEM_FREE (ret_buf.pointer);
603 }
604 }
605 else if (obj_desc->reference.object) {
606 acpi_os_printf ("\nReferenced Object: %p\n", obj_desc->reference.object);
607 }
608}
609
610
611/*******************************************************************************
612 *
613 * FUNCTION: acpi_ex_dump_package
614 *
615 * PARAMETERS: Object - Descriptor to dump
616 * Level - Indentation Level
617 * Index - Package index for this object
618 *
619 * DESCRIPTION: Dumps the elements of the package
620 *
621 ******************************************************************************/
622
623static void
624acpi_ex_dump_package (
625 union acpi_operand_object *obj_desc,
626 u32 level,
627 u32 index)
628{
629 u32 i;
630
631
632 /* Indentation and index output */
633
634 if (level > 0) {
635 for (i = 0; i < level; i++) {
636 acpi_os_printf (" ");
637 }
638
639 acpi_os_printf ("[%.2d] ", index);
640 }
641
642 acpi_os_printf ("%p ", obj_desc);
643
644 /* Null package elements are allowed */
645
646 if (!obj_desc) {
647 acpi_os_printf ("[Null Object]\n");
648 return;
649 }
650
651 /* Packages may only contain a few object types */
652
653 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
654 case ACPI_TYPE_INTEGER:
655
656 acpi_os_printf ("[Integer] = %8.8X%8.8X\n",
657 ACPI_FORMAT_UINT64 (obj_desc->integer.value));
658 break;
659
660
661 case ACPI_TYPE_STRING:
662
663 acpi_os_printf ("[String] Value: ");
664 for (i = 0; i < obj_desc->string.length; i++) {
665 acpi_os_printf ("%c", obj_desc->string.pointer[i]);
666 }
667 acpi_os_printf ("\n");
668 break;
669
670
671 case ACPI_TYPE_BUFFER:
672
673 acpi_os_printf ("[Buffer] Length %.2X = ", obj_desc->buffer.length);
674 if (obj_desc->buffer.length) {
675 acpi_ut_dump_buffer ((u8 *) obj_desc->buffer.pointer,
676 obj_desc->buffer.length, DB_DWORD_DISPLAY, _COMPONENT);
677 }
678 else {
679 acpi_os_printf ("\n");
680 }
681 break;
682
683
684 case ACPI_TYPE_PACKAGE:
685
686 acpi_os_printf ("[Package] Contains %d Elements: \n",
687 obj_desc->package.count);
688
689 for (i = 0; i < obj_desc->package.count; i++) {
690 acpi_ex_dump_package (obj_desc->package.elements[i], level+1, i);
691 }
692 break;
693
694
695 case ACPI_TYPE_LOCAL_REFERENCE:
696
697 acpi_os_printf ("[Object Reference] ");
698 acpi_ex_dump_reference (obj_desc);
699 break;
700
701
702 default:
703
704 acpi_os_printf ("[Unknown Type] %X\n", ACPI_GET_OBJECT_TYPE (obj_desc));
705 break;
706 }
707}
708
709
710/*******************************************************************************
711 *
568 * FUNCTION: acpi_ex_dump_object_descriptor 712 * FUNCTION: acpi_ex_dump_object_descriptor
569 * 713 *
570 * PARAMETERS: *Object - Descriptor to dump 714 * PARAMETERS: Object - Descriptor to dump
571 * Flags - Force display if TRUE 715 * Flags - Force display if TRUE
572 * 716 *
573 * DESCRIPTION: Dumps the members of the object descriptor given. 717 * DESCRIPTION: Dumps the members of the object descriptor given.
@@ -579,9 +723,6 @@ acpi_ex_dump_object_descriptor (
579 union acpi_operand_object *obj_desc, 723 union acpi_operand_object *obj_desc,
580 u32 flags) 724 u32 flags)
581{ 725{
582 u32 i;
583
584
585 ACPI_FUNCTION_TRACE ("ex_dump_object_descriptor"); 726 ACPI_FUNCTION_TRACE ("ex_dump_object_descriptor");
586 727
587 728
@@ -648,22 +789,13 @@ acpi_ex_dump_object_descriptor (
648 case ACPI_TYPE_PACKAGE: 789 case ACPI_TYPE_PACKAGE:
649 790
650 acpi_ex_out_integer ("Flags", obj_desc->package.flags); 791 acpi_ex_out_integer ("Flags", obj_desc->package.flags);
651 acpi_ex_out_integer ("Count", obj_desc->package.count); 792 acpi_ex_out_integer ("Elements", obj_desc->package.count);
652 acpi_ex_out_pointer ("Elements", obj_desc->package.elements); 793 acpi_ex_out_pointer ("Element List", obj_desc->package.elements);
653 794
654 /* Dump the package contents */ 795 /* Dump the package contents */
655 796
656 if (obj_desc->package.count > 0) { 797 acpi_os_printf ("\nPackage Contents:\n");
657 acpi_os_printf ("\nPackage Contents:\n"); 798 acpi_ex_dump_package (obj_desc, 0, 0);
658 for (i = 0; i < obj_desc->package.count; i++) {
659 acpi_os_printf ("[%.3d] %p", i, obj_desc->package.elements[i]);
660 if (obj_desc->package.elements[i]) {
661 acpi_os_printf (" %s",
662 acpi_ut_get_object_type_name (obj_desc->package.elements[i]));
663 }
664 acpi_os_printf ("\n");
665 }
666 }
667 break; 799 break;
668 800
669 801
@@ -686,7 +818,7 @@ acpi_ex_dump_object_descriptor (
686 acpi_ex_out_integer ("param_count", obj_desc->method.param_count); 818 acpi_ex_out_integer ("param_count", obj_desc->method.param_count);
687 acpi_ex_out_integer ("Concurrency", obj_desc->method.concurrency); 819 acpi_ex_out_integer ("Concurrency", obj_desc->method.concurrency);
688 acpi_ex_out_pointer ("Semaphore", obj_desc->method.semaphore); 820 acpi_ex_out_pointer ("Semaphore", obj_desc->method.semaphore);
689 acpi_ex_out_integer ("owning_id", obj_desc->method.owning_id); 821 acpi_ex_out_integer ("owner_id", obj_desc->method.owner_id);
690 acpi_ex_out_integer ("aml_length", obj_desc->method.aml_length); 822 acpi_ex_out_integer ("aml_length", obj_desc->method.aml_length);
691 acpi_ex_out_pointer ("aml_start", obj_desc->method.aml_start); 823 acpi_ex_out_pointer ("aml_start", obj_desc->method.aml_start);
692 break; 824 break;
@@ -790,10 +922,7 @@ acpi_ex_dump_object_descriptor (
790 acpi_ex_out_pointer ("Node", obj_desc->reference.node); 922 acpi_ex_out_pointer ("Node", obj_desc->reference.node);
791 acpi_ex_out_pointer ("Where", obj_desc->reference.where); 923 acpi_ex_out_pointer ("Where", obj_desc->reference.where);
792 924
793 if (obj_desc->reference.object) { 925 acpi_ex_dump_reference (obj_desc);
794 acpi_os_printf ("\nReferenced Object:\n");
795 acpi_ex_dump_object_descriptor (obj_desc->reference.object, flags);
796 }
797 break; 926 break;
798 927
799 928
diff --git a/drivers/acpi/executer/exfield.c b/drivers/acpi/executer/exfield.c
index 22c8fa480f60..a690c9250990 100644
--- a/drivers/acpi/executer/exfield.c
+++ b/drivers/acpi/executer/exfield.c
@@ -87,6 +87,9 @@ acpi_ex_read_data_from_field (
87 if (!obj_desc) { 87 if (!obj_desc) {
88 return_ACPI_STATUS (AE_AML_NO_OPERAND); 88 return_ACPI_STATUS (AE_AML_NO_OPERAND);
89 } 89 }
90 if (!ret_buffer_desc) {
91 return_ACPI_STATUS (AE_BAD_PARAMETER);
92 }
90 93
91 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_BUFFER_FIELD) { 94 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_BUFFER_FIELD) {
92 /* 95 /*
@@ -182,7 +185,7 @@ exit:
182 if (ACPI_FAILURE (status)) { 185 if (ACPI_FAILURE (status)) {
183 acpi_ut_remove_reference (buffer_desc); 186 acpi_ut_remove_reference (buffer_desc);
184 } 187 }
185 else if (ret_buffer_desc) { 188 else {
186 *ret_buffer_desc = buffer_desc; 189 *ret_buffer_desc = buffer_desc;
187 } 190 }
188 191
diff --git a/drivers/acpi/executer/exmisc.c b/drivers/acpi/executer/exmisc.c
index 022f281345b8..237ef28c8132 100644
--- a/drivers/acpi/executer/exmisc.c
+++ b/drivers/acpi/executer/exmisc.c
@@ -302,7 +302,7 @@ acpi_ex_do_concatenate (
302 /* Result of two Integers is a Buffer */ 302 /* Result of two Integers is a Buffer */
303 /* Need enough buffer space for two integers */ 303 /* Need enough buffer space for two integers */
304 304
305 return_desc = acpi_ut_create_buffer_object ( 305 return_desc = acpi_ut_create_buffer_object ((acpi_size)
306 ACPI_MUL_2 (acpi_gbl_integer_byte_width)); 306 ACPI_MUL_2 (acpi_gbl_integer_byte_width));
307 if (!return_desc) { 307 if (!return_desc) {
308 status = AE_NO_MEMORY; 308 status = AE_NO_MEMORY;
diff --git a/drivers/acpi/executer/exnames.c b/drivers/acpi/executer/exnames.c
index 639f0bd3f6d8..b6ba1a7a677a 100644
--- a/drivers/acpi/executer/exnames.c
+++ b/drivers/acpi/executer/exnames.c
@@ -438,6 +438,13 @@ acpi_ex_get_name_string (
438 status = AE_AML_BAD_NAME; 438 status = AE_AML_BAD_NAME;
439 } 439 }
440 440
441 if (ACPI_FAILURE (status)) {
442 if (name_string) {
443 ACPI_MEM_FREE (name_string);
444 }
445 return_ACPI_STATUS (status);
446 }
447
441 *out_name_string = name_string; 448 *out_name_string = name_string;
442 *out_name_length = (u32) (aml_address - in_aml_address); 449 *out_name_length = (u32) (aml_address - in_aml_address);
443 450
diff --git a/drivers/acpi/executer/exoparg1.c b/drivers/acpi/executer/exoparg1.c
index dbdf8262ba00..c1ba8b48228e 100644
--- a/drivers/acpi/executer/exoparg1.c
+++ b/drivers/acpi/executer/exoparg1.c
@@ -113,8 +113,9 @@ acpi_ex_opcode_0A_0T_1R (
113 status = AE_NO_MEMORY; 113 status = AE_NO_MEMORY;
114 goto cleanup; 114 goto cleanup;
115 } 115 }
116 116#if ACPI_MACHINE_WIDTH != 16
117 return_desc->integer.value = acpi_os_get_timer (); 117 return_desc->integer.value = acpi_os_get_timer ();
118#endif
118 break; 119 break;
119 120
120 default: /* Unknown opcode */ 121 default: /* Unknown opcode */
@@ -127,15 +128,16 @@ acpi_ex_opcode_0A_0T_1R (
127 128
128cleanup: 129cleanup:
129 130
130 if (!walk_state->result_obj) {
131 walk_state->result_obj = return_desc;
132 }
133
134 /* Delete return object on error */ 131 /* Delete return object on error */
135 132
136 if (ACPI_FAILURE (status)) { 133 if ((ACPI_FAILURE (status)) || walk_state->result_obj) {
137 acpi_ut_remove_reference (return_desc); 134 acpi_ut_remove_reference (return_desc);
138 } 135 }
136 else {
137 /* Save the return value */
138
139 walk_state->result_obj = return_desc;
140 }
139 141
140 return_ACPI_STATUS (status); 142 return_ACPI_STATUS (status);
141} 143}
@@ -902,6 +904,7 @@ acpi_ex_opcode_1A_0T_1R (
902 */ 904 */
903 return_desc = acpi_ns_get_attached_object ( 905 return_desc = acpi_ns_get_attached_object (
904 (struct acpi_namespace_node *) operand[0]); 906 (struct acpi_namespace_node *) operand[0]);
907 acpi_ut_add_reference (return_desc);
905 } 908 }
906 else { 909 else {
907 /* 910 /*
@@ -951,20 +954,10 @@ acpi_ex_opcode_1A_0T_1R (
951 * add another reference to the referenced object, however. 954 * add another reference to the referenced object, however.
952 */ 955 */
953 return_desc = *(operand[0]->reference.where); 956 return_desc = *(operand[0]->reference.where);
954 if (!return_desc) { 957 if (return_desc) {
955 /* 958 acpi_ut_add_reference (return_desc);
956 * We can't return a NULL dereferenced value. This is
957 * an uninitialized package element and is thus a
958 * severe error.
959 */
960 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
961 "NULL package element obj %p\n",
962 operand[0]));
963 status = AE_AML_UNINITIALIZED_ELEMENT;
964 goto cleanup;
965 } 959 }
966 960
967 acpi_ut_add_reference (return_desc);
968 break; 961 break;
969 962
970 963
diff --git a/drivers/acpi/executer/exoparg3.c b/drivers/acpi/executer/exoparg3.c
index 23b068adbf58..197890f443b5 100644
--- a/drivers/acpi/executer/exoparg3.c
+++ b/drivers/acpi/executer/exoparg3.c
@@ -160,7 +160,7 @@ acpi_ex_opcode_3A_1T_1R (
160{ 160{
161 union acpi_operand_object **operand = &walk_state->operands[0]; 161 union acpi_operand_object **operand = &walk_state->operands[0];
162 union acpi_operand_object *return_desc = NULL; 162 union acpi_operand_object *return_desc = NULL;
163 char *buffer; 163 char *buffer = NULL;
164 acpi_status status = AE_OK; 164 acpi_status status = AE_OK;
165 acpi_integer index; 165 acpi_integer index;
166 acpi_size length; 166 acpi_size length;
@@ -193,34 +193,63 @@ acpi_ex_opcode_3A_1T_1R (
193 * If the index is beyond the length of the String/Buffer, or if the 193 * If the index is beyond the length of the String/Buffer, or if the
194 * requested length is zero, return a zero-length String/Buffer 194 * requested length is zero, return a zero-length String/Buffer
195 */ 195 */
196 if ((index < operand[0]->string.length) && 196 if (index >= operand[0]->string.length) {
197 (length > 0)) { 197 length = 0;
198 /* Truncate request if larger than the actual String/Buffer */ 198 }
199 199
200 if ((index + length) > 200 /* Truncate request if larger than the actual String/Buffer */
201 operand[0]->string.length) { 201
202 length = (acpi_size) operand[0]->string.length - 202 else if ((index + length) > operand[0]->string.length) {
203 (acpi_size) index; 203 length = (acpi_size) operand[0]->string.length -
204 } 204 (acpi_size) index;
205 }
205 206
206 /* Allocate a new buffer for the String/Buffer */ 207 /* Strings always have a sub-pointer, not so for buffers */
208
209 switch (ACPI_GET_OBJECT_TYPE (operand[0])) {
210 case ACPI_TYPE_STRING:
211
212 /* Always allocate a new buffer for the String */
207 213
208 buffer = ACPI_MEM_CALLOCATE ((acpi_size) length + 1); 214 buffer = ACPI_MEM_CALLOCATE ((acpi_size) length + 1);
209 if (!buffer) { 215 if (!buffer) {
210 status = AE_NO_MEMORY; 216 status = AE_NO_MEMORY;
211 goto cleanup; 217 goto cleanup;
212 } 218 }
219 break;
220
221 case ACPI_TYPE_BUFFER:
222
223 /* If the requested length is zero, don't allocate a buffer */
224
225 if (length > 0) {
226 /* Allocate a new buffer for the Buffer */
227
228 buffer = ACPI_MEM_CALLOCATE (length);
229 if (!buffer) {
230 status = AE_NO_MEMORY;
231 goto cleanup;
232 }
233 }
234 break;
213 235
236 default: /* Should not happen */
237
238 status = AE_AML_OPERAND_TYPE;
239 goto cleanup;
240 }
241
242 if (length > 0) {
214 /* Copy the portion requested */ 243 /* Copy the portion requested */
215 244
216 ACPI_MEMCPY (buffer, operand[0]->string.pointer + index, 245 ACPI_MEMCPY (buffer, operand[0]->string.pointer + index,
217 length); 246 length);
247 }
218 248
219 /* Set the length of the new String/Buffer */ 249 /* Set the length of the new String/Buffer */
220 250
221 return_desc->string.pointer = buffer; 251 return_desc->string.pointer = buffer;
222 return_desc->string.length = (u32) length; 252 return_desc->string.length = (u32) length;
223 }
224 253
225 /* Mark buffer initialized */ 254 /* Mark buffer initialized */
226 255
@@ -244,13 +273,13 @@ cleanup:
244 273
245 /* Delete return object on error */ 274 /* Delete return object on error */
246 275
247 if (ACPI_FAILURE (status)) { 276 if (ACPI_FAILURE (status) || walk_state->result_obj) {
248 acpi_ut_remove_reference (return_desc); 277 acpi_ut_remove_reference (return_desc);
249 } 278 }
250 279
251 /* Set the return object and exit */ 280 /* Set the return object and exit */
252 281
253 if (!walk_state->result_obj) { 282 else {
254 walk_state->result_obj = return_desc; 283 walk_state->result_obj = return_desc;
255 } 284 }
256 return_ACPI_STATUS (status); 285 return_ACPI_STATUS (status);
diff --git a/drivers/acpi/executer/exresop.c b/drivers/acpi/executer/exresop.c
index d8b470eefe7a..aaba7abcb52d 100644
--- a/drivers/acpi/executer/exresop.c
+++ b/drivers/acpi/executer/exresop.c
@@ -426,6 +426,10 @@ acpi_ex_resolve_operands (
426 426
427 return_ACPI_STATUS (status); 427 return_ACPI_STATUS (status);
428 } 428 }
429
430 if (obj_desc != *stack_ptr) {
431 acpi_ut_remove_reference (obj_desc);
432 }
429 goto next_operand; 433 goto next_operand;
430 434
431 435
@@ -448,6 +452,10 @@ acpi_ex_resolve_operands (
448 452
449 return_ACPI_STATUS (status); 453 return_ACPI_STATUS (status);
450 } 454 }
455
456 if (obj_desc != *stack_ptr) {
457 acpi_ut_remove_reference (obj_desc);
458 }
451 goto next_operand; 459 goto next_operand;
452 460
453 461
@@ -471,6 +479,10 @@ acpi_ex_resolve_operands (
471 479
472 return_ACPI_STATUS (status); 480 return_ACPI_STATUS (status);
473 } 481 }
482
483 if (obj_desc != *stack_ptr) {
484 acpi_ut_remove_reference (obj_desc);
485 }
474 goto next_operand; 486 goto next_operand;
475 487
476 488
@@ -515,6 +527,10 @@ acpi_ex_resolve_operands (
515 if (ACPI_FAILURE (status)) { 527 if (ACPI_FAILURE (status)) {
516 return_ACPI_STATUS (status); 528 return_ACPI_STATUS (status);
517 } 529 }
530
531 if (obj_desc != *stack_ptr) {
532 acpi_ut_remove_reference (obj_desc);
533 }
518 break; 534 break;
519 535
520 default: 536 default:
diff --git a/drivers/acpi/executer/exstore.c b/drivers/acpi/executer/exstore.c
index 2725db0901b8..59dbfeaa54c0 100644
--- a/drivers/acpi/executer/exstore.c
+++ b/drivers/acpi/executer/exstore.c
@@ -147,7 +147,7 @@ acpi_ex_do_debug_object (
147 147
148 case ACPI_TYPE_BUFFER: 148 case ACPI_TYPE_BUFFER:
149 149
150 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]", 150 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]\n",
151 (u32) source_desc->buffer.length)); 151 (u32) source_desc->buffer.length));
152 ACPI_DUMP_BUFFER (source_desc->buffer.pointer, 152 ACPI_DUMP_BUFFER (source_desc->buffer.pointer,
153 (source_desc->buffer.length < 32) ? source_desc->buffer.length : 32); 153 (source_desc->buffer.length < 32) ? source_desc->buffer.length : 32);
@@ -574,7 +574,7 @@ acpi_ex_store_object_to_node (
574 574
575 /* If no implicit conversion, drop into the default case below */ 575 /* If no implicit conversion, drop into the default case below */
576 576
577 if (!implicit_conversion) { 577 if ((!implicit_conversion) || (walk_state->opcode == AML_COPY_OP)) {
578 /* Force execution of default (no implicit conversion) */ 578 /* Force execution of default (no implicit conversion) */
579 579
580 target_type = ACPI_TYPE_ANY; 580 target_type = ACPI_TYPE_ANY;
@@ -634,7 +634,7 @@ acpi_ex_store_object_to_node (
634 default: 634 default:
635 635
636 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 636 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
637 "Storing %s (%p) directly into node (%p), no implicit conversion\n", 637 "Storing %s (%p) directly into node (%p) with no implicit conversion\n",
638 acpi_ut_get_object_type_name (source_desc), source_desc, node)); 638 acpi_ut_get_object_type_name (source_desc), source_desc, node));
639 639
640 /* No conversions for all other types. Just attach the source object */ 640 /* No conversions for all other types. Just attach the source object */
diff --git a/drivers/acpi/executer/exstoren.c b/drivers/acpi/executer/exstoren.c
index 120f30ed0bd4..433588ab432a 100644
--- a/drivers/acpi/executer/exstoren.c
+++ b/drivers/acpi/executer/exstoren.c
@@ -265,10 +265,6 @@ acpi_ex_store_object_to_object (
265 265
266 case ACPI_TYPE_BUFFER: 266 case ACPI_TYPE_BUFFER:
267 267
268 /*
269 * Note: There is different store behavior depending on the original
270 * source type
271 */
272 status = acpi_ex_store_buffer_to_buffer (actual_src_desc, dest_desc); 268 status = acpi_ex_store_buffer_to_buffer (actual_src_desc, dest_desc);
273 break; 269 break;
274 270
diff --git a/drivers/acpi/executer/exutils.c b/drivers/acpi/executer/exutils.c
index 5c7ec0c04177..d00b0dcba96a 100644
--- a/drivers/acpi/executer/exutils.c
+++ b/drivers/acpi/executer/exutils.c
@@ -369,7 +369,7 @@ acpi_ex_eisa_id_to_string (
369 * 369 *
370 * RETURN: None, string 370 * RETURN: None, string
371 * 371 *
372 * DESCRIPTOIN: Convert a number to string representation. Assumes string 372 * DESCRIPTION: Convert a number to string representation. Assumes string
373 * buffer is large enough to hold the string. 373 * buffer is large enough to hold the string.
374 * 374 *
375 ******************************************************************************/ 375 ******************************************************************************/