diff options
Diffstat (limited to 'drivers/acpi/utilities/utcopy.c')
-rw-r--r-- | drivers/acpi/utilities/utcopy.c | 46 |
1 files changed, 19 insertions, 27 deletions
diff --git a/drivers/acpi/utilities/utcopy.c b/drivers/acpi/utilities/utcopy.c index 11e884957162..31c30a32e5c9 100644 --- a/drivers/acpi/utilities/utcopy.c +++ b/drivers/acpi/utilities/utcopy.c | |||
@@ -694,58 +694,50 @@ acpi_ut_copy_simple_object ( | |||
694 | dest_desc->common.reference_count = reference_count; | 694 | dest_desc->common.reference_count = reference_count; |
695 | dest_desc->common.next_object = next_object; | 695 | dest_desc->common.next_object = next_object; |
696 | 696 | ||
697 | /* New object is not static, regardless of source */ | ||
698 | |||
699 | dest_desc->common.flags &= ~AOPOBJ_STATIC_POINTER; | ||
700 | |||
697 | /* Handle the objects with extra data */ | 701 | /* Handle the objects with extra data */ |
698 | 702 | ||
699 | switch (ACPI_GET_OBJECT_TYPE (dest_desc)) { | 703 | switch (ACPI_GET_OBJECT_TYPE (dest_desc)) { |
700 | case ACPI_TYPE_BUFFER: | 704 | case ACPI_TYPE_BUFFER: |
701 | |||
702 | dest_desc->buffer.node = NULL; | ||
703 | dest_desc->common.flags = source_desc->common.flags; | ||
704 | |||
705 | /* | 705 | /* |
706 | * Allocate and copy the actual buffer if and only if: | 706 | * Allocate and copy the actual buffer if and only if: |
707 | * 1) There is a valid buffer pointer | 707 | * 1) There is a valid buffer pointer |
708 | * 2) The buffer is not static (not in an ACPI table) (in this case, | 708 | * 2) The buffer has a length > 0 |
709 | * the actual pointer was already copied above) | ||
710 | */ | 709 | */ |
711 | if ((source_desc->buffer.pointer) && | 710 | if ((source_desc->buffer.pointer) && |
712 | (!(source_desc->common.flags & AOPOBJ_STATIC_POINTER))) { | 711 | (source_desc->buffer.length)) { |
713 | dest_desc->buffer.pointer = NULL; | 712 | dest_desc->buffer.pointer = |
714 | 713 | ACPI_MEM_ALLOCATE (source_desc->buffer.length); | |
715 | /* Create an actual buffer only if length > 0 */ | 714 | if (!dest_desc->buffer.pointer) { |
716 | 715 | return (AE_NO_MEMORY); | |
717 | if (source_desc->buffer.length) { | 716 | } |
718 | dest_desc->buffer.pointer = | ||
719 | ACPI_MEM_ALLOCATE (source_desc->buffer.length); | ||
720 | if (!dest_desc->buffer.pointer) { | ||
721 | return (AE_NO_MEMORY); | ||
722 | } | ||
723 | 717 | ||
724 | /* Copy the actual buffer data */ | 718 | /* Copy the actual buffer data */ |
725 | 719 | ||
726 | ACPI_MEMCPY (dest_desc->buffer.pointer, | 720 | ACPI_MEMCPY (dest_desc->buffer.pointer, |
727 | source_desc->buffer.pointer, | 721 | source_desc->buffer.pointer, |
728 | source_desc->buffer.length); | 722 | source_desc->buffer.length); |
729 | } | ||
730 | } | 723 | } |
731 | break; | 724 | break; |
732 | 725 | ||
733 | case ACPI_TYPE_STRING: | 726 | case ACPI_TYPE_STRING: |
734 | |||
735 | /* | 727 | /* |
736 | * Allocate and copy the actual string if and only if: | 728 | * Allocate and copy the actual string if and only if: |
737 | * 1) There is a valid string pointer | 729 | * 1) There is a valid string pointer |
738 | * 2) The string is not static (not in an ACPI table) (in this case, | 730 | * (Pointer to a NULL string is allowed) |
739 | * the actual pointer was already copied above) | ||
740 | */ | 731 | */ |
741 | if ((source_desc->string.pointer) && | 732 | if (source_desc->string.pointer) { |
742 | (!(source_desc->common.flags & AOPOBJ_STATIC_POINTER))) { | ||
743 | dest_desc->string.pointer = | 733 | dest_desc->string.pointer = |
744 | ACPI_MEM_ALLOCATE ((acpi_size) source_desc->string.length + 1); | 734 | ACPI_MEM_ALLOCATE ((acpi_size) source_desc->string.length + 1); |
745 | if (!dest_desc->string.pointer) { | 735 | if (!dest_desc->string.pointer) { |
746 | return (AE_NO_MEMORY); | 736 | return (AE_NO_MEMORY); |
747 | } | 737 | } |
748 | 738 | ||
739 | /* Copy the actual string data */ | ||
740 | |||
749 | ACPI_MEMCPY (dest_desc->string.pointer, source_desc->string.pointer, | 741 | ACPI_MEMCPY (dest_desc->string.pointer, source_desc->string.pointer, |
750 | (acpi_size) source_desc->string.length + 1); | 742 | (acpi_size) source_desc->string.length + 1); |
751 | } | 743 | } |