1 /******************************************************************************* 2 * 3 * Module Name: utdelete - object deletion and reference count utilities 4 * 5 ******************************************************************************/ 6 7 /* 8 * Copyright (C) 2000 - 2019, Intel Corp. 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions, and the following disclaimer, 16 * without modification. 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18 * substantially similar to the "NO WARRANTY" disclaimer below 19 * ("Disclaimer") and any redistribution must be conditioned upon 20 * including a substantially similar Disclaimer requirement for further 21 * binary redistribution. 22 * 3. Neither the names of the above-listed copyright holders nor the names 23 * of any contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * Alternatively, this software may be distributed under the terms of the 27 * GNU General Public License ("GPL") version 2 as published by the Free 28 * Software Foundation. 29 * 30 * NO WARRANTY 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41 * POSSIBILITY OF SUCH DAMAGES. 42 */ 43 44 #include "acpi.h" 45 #include "accommon.h" 46 #include "acinterp.h" 47 #include "acnamesp.h" 48 #include "acevents.h" 49 50 51 #define _COMPONENT ACPI_UTILITIES 52 ACPI_MODULE_NAME ("utdelete") 53 54 /* Local prototypes */ 55 56 static void 57 AcpiUtDeleteInternalObj ( 58 ACPI_OPERAND_OBJECT *Object); 59 60 static void 61 AcpiUtUpdateRefCount ( 62 ACPI_OPERAND_OBJECT *Object, 63 UINT32 Action); 64 65 66 /******************************************************************************* 67 * 68 * FUNCTION: AcpiUtDeleteInternalObj 69 * 70 * PARAMETERS: Object - Object to be deleted 71 * 72 * RETURN: None 73 * 74 * DESCRIPTION: Low level object deletion, after reference counts have been 75 * updated (All reference counts, including sub-objects!) 76 * 77 ******************************************************************************/ 78 79 static void 80 AcpiUtDeleteInternalObj ( 81 ACPI_OPERAND_OBJECT *Object) 82 { 83 void *ObjPointer = NULL; 84 ACPI_OPERAND_OBJECT *HandlerDesc; 85 ACPI_OPERAND_OBJECT *SecondDesc; 86 ACPI_OPERAND_OBJECT *NextDesc; 87 ACPI_OPERAND_OBJECT *StartDesc; 88 ACPI_OPERAND_OBJECT **LastObjPtr; 89 90 91 ACPI_FUNCTION_TRACE_PTR (UtDeleteInternalObj, Object); 92 93 94 if (!Object) 95 { 96 return_VOID; 97 } 98 99 /* 100 * Must delete or free any pointers within the object that are not 101 * actual ACPI objects (for example, a raw buffer pointer). 102 */ 103 switch (Object->Common.Type) 104 { 105 case ACPI_TYPE_STRING: 106 107 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** String %p, ptr %p\n", 108 Object, Object->String.Pointer)); 109 110 /* Free the actual string buffer */ 111 112 if (!(Object->Common.Flags & AOPOBJ_STATIC_POINTER)) 113 { 114 /* But only if it is NOT a pointer into an ACPI table */ 115 116 ObjPointer = Object->String.Pointer; 117 } 118 break; 119 120 case ACPI_TYPE_BUFFER: 121 122 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** Buffer %p, ptr %p\n", 123 Object, Object->Buffer.Pointer)); 124 125 /* Free the actual buffer */ 126 127 if (!(Object->Common.Flags & AOPOBJ_STATIC_POINTER)) 128 { 129 /* But only if it is NOT a pointer into an ACPI table */ 130 131 ObjPointer = Object->Buffer.Pointer; 132 } 133 break; 134 135 case ACPI_TYPE_PACKAGE: 136 137 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, " **** Package of count %X\n", 138 Object->Package.Count)); 139 140 /* 141 * Elements of the package are not handled here, they are deleted 142 * separately 143 */ 144 145 /* Free the (variable length) element pointer array */ 146 147 ObjPointer = Object->Package.Elements; 148 break; 149 150 /* 151 * These objects have a possible list of notify handlers. 152 * Device object also may have a GPE block. 153 */ 154 case ACPI_TYPE_DEVICE: 155 156 if (Object->Device.GpeBlock) 157 { 158 (void) AcpiEvDeleteGpeBlock (Object->Device.GpeBlock); 159 } 160 161 /*lint -fallthrough */ 162 163 case ACPI_TYPE_PROCESSOR: 164 case ACPI_TYPE_THERMAL: 165 166 /* Walk the address handler list for this object */ 167 168 HandlerDesc = Object->CommonNotify.Handler; 169 while (HandlerDesc) 170 { 171 NextDesc = HandlerDesc->AddressSpace.Next; 172 AcpiUtRemoveReference (HandlerDesc); 173 HandlerDesc = NextDesc; 174 } 175 break; 176 177 case ACPI_TYPE_MUTEX: 178 179 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 180 "***** Mutex %p, OS Mutex %p\n", 181 Object, Object->Mutex.OsMutex)); 182 183 if (Object == AcpiGbl_GlobalLockMutex) 184 { 185 /* Global Lock has extra semaphore */ 186 187 (void) AcpiOsDeleteSemaphore (AcpiGbl_GlobalLockSemaphore); 188 AcpiGbl_GlobalLockSemaphore = NULL; 189 190 AcpiOsDeleteMutex (Object->Mutex.OsMutex); 191 AcpiGbl_GlobalLockMutex = NULL; 192 } 193 else 194 { 195 AcpiExUnlinkMutex (Object); 196 AcpiOsDeleteMutex (Object->Mutex.OsMutex); 197 } 198 break; 199 200 case ACPI_TYPE_EVENT: 201 202 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 203 "***** Event %p, OS Semaphore %p\n", 204 Object, Object->Event.OsSemaphore)); 205 206 (void) AcpiOsDeleteSemaphore (Object->Event.OsSemaphore); 207 Object->Event.OsSemaphore = NULL; 208 break; 209 210 case ACPI_TYPE_METHOD: 211 212 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 213 "***** Method %p\n", Object)); 214 215 /* Delete the method mutex if it exists */ 216 217 if (Object->Method.Mutex) 218 { 219 AcpiOsDeleteMutex (Object->Method.Mutex->Mutex.OsMutex); 220 AcpiUtDeleteObjectDesc (Object->Method.Mutex); 221 Object->Method.Mutex = NULL; 222 } 223 224 if (Object->Method.Node) 225 { 226 Object->Method.Node = NULL; 227 } 228 break; 229 230 case ACPI_TYPE_REGION: 231 232 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 233 "***** Region %p\n", Object)); 234 235 /* 236 * Update AddressRange list. However, only permanent regions 237 * are installed in this list. (Not created within a method) 238 */ 239 if (!(Object->Region.Node->Flags & ANOBJ_TEMPORARY)) 240 { 241 AcpiUtRemoveAddressRange (Object->Region.SpaceId, 242 Object->Region.Node); 243 } 244 245 SecondDesc = AcpiNsGetSecondaryObject (Object); 246 if (SecondDesc) 247 { 248 /* 249 * Free the RegionContext if and only if the handler is one of the 250 * default handlers -- and therefore, we created the context object 251 * locally, it was not created by an external caller. 252 */ 253 HandlerDesc = Object->Region.Handler; 254 if (HandlerDesc) 255 { 256 NextDesc = HandlerDesc->AddressSpace.RegionList; 257 StartDesc = NextDesc; 258 LastObjPtr = &HandlerDesc->AddressSpace.RegionList; 259 260 /* Remove the region object from the handler list */ 261 262 while (NextDesc) 263 { 264 if (NextDesc == Object) 265 { 266 *LastObjPtr = NextDesc->Region.Next; 267 break; 268 } 269 270 /* Walk the linked list of handlers */ 271 272 LastObjPtr = &NextDesc->Region.Next; 273 NextDesc = NextDesc->Region.Next; 274 275 /* Prevent infinite loop if list is corrupted */ 276 277 if (NextDesc == StartDesc) 278 { 279 ACPI_ERROR ((AE_INFO, 280 "Circular region list in address handler object %p", 281 HandlerDesc)); 282 return_VOID; 283 } 284 } 285 286 if (HandlerDesc->AddressSpace.HandlerFlags & 287 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) 288 { 289 /* Deactivate region and free region context */ 290 291 if (HandlerDesc->AddressSpace.Setup) 292 { 293 (void) HandlerDesc->AddressSpace.Setup (Object, 294 ACPI_REGION_DEACTIVATE, 295 HandlerDesc->AddressSpace.Context, 296 &SecondDesc->Extra.RegionContext); 297 } 298 } 299 300 AcpiUtRemoveReference (HandlerDesc); 301 } 302 303 /* Now we can free the Extra object */ 304 305 AcpiUtDeleteObjectDesc (SecondDesc); 306 } 307 break; 308 309 case ACPI_TYPE_BUFFER_FIELD: 310 311 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 312 "***** Buffer Field %p\n", Object)); 313 314 SecondDesc = AcpiNsGetSecondaryObject (Object); 315 if (SecondDesc) 316 { 317 AcpiUtDeleteObjectDesc (SecondDesc); 318 } 319 break; 320 321 case ACPI_TYPE_LOCAL_BANK_FIELD: 322 323 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 324 "***** Bank Field %p\n", Object)); 325 326 SecondDesc = AcpiNsGetSecondaryObject (Object); 327 if (SecondDesc) 328 { 329 AcpiUtDeleteObjectDesc (SecondDesc); 330 } 331 break; 332 333 default: 334 335 break; 336 } 337 338 /* Free any allocated memory (pointer within the object) found above */ 339 340 if (ObjPointer) 341 { 342 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object Subptr %p\n", 343 ObjPointer)); 344 ACPI_FREE (ObjPointer); 345 } 346 347 /* Now the object can be safely deleted */ 348 349 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_ALLOCATIONS, "%s: Deleting Object %p [%s]\n", 350 ACPI_GET_FUNCTION_NAME, Object, AcpiUtGetObjectTypeName (Object))); 351 352 AcpiUtDeleteObjectDesc (Object); 353 return_VOID; 354 } 355 356 357 /******************************************************************************* 358 * 359 * FUNCTION: AcpiUtDeleteInternalObjectList 360 * 361 * PARAMETERS: ObjList - Pointer to the list to be deleted 362 * 363 * RETURN: None 364 * 365 * DESCRIPTION: This function deletes an internal object list, including both 366 * simple objects and package objects 367 * 368 ******************************************************************************/ 369 370 void 371 AcpiUtDeleteInternalObjectList ( 372 ACPI_OPERAND_OBJECT **ObjList) 373 { 374 ACPI_OPERAND_OBJECT **InternalObj; 375 376 377 ACPI_FUNCTION_ENTRY (); 378 379 380 /* Walk the null-terminated internal list */ 381 382 for (InternalObj = ObjList; *InternalObj; InternalObj++) 383 { 384 AcpiUtRemoveReference (*InternalObj); 385 } 386 387 /* Free the combined parameter pointer list and object array */ 388 389 ACPI_FREE (ObjList); 390 return; 391 } 392 393 394 /******************************************************************************* 395 * 396 * FUNCTION: AcpiUtUpdateRefCount 397 * 398 * PARAMETERS: Object - Object whose ref count is to be updated 399 * Action - What to do (REF_INCREMENT or REF_DECREMENT) 400 * 401 * RETURN: None. Sets new reference count within the object 402 * 403 * DESCRIPTION: Modify the reference count for an internal acpi object 404 * 405 ******************************************************************************/ 406 407 static void 408 AcpiUtUpdateRefCount ( 409 ACPI_OPERAND_OBJECT *Object, 410 UINT32 Action) 411 { 412 UINT16 OriginalCount; 413 UINT16 NewCount = 0; 414 ACPI_CPU_FLAGS LockFlags; 415 char *Message; 416 417 418 ACPI_FUNCTION_NAME (UtUpdateRefCount); 419 420 421 if (!Object) 422 { 423 return; 424 } 425 426 /* 427 * Always get the reference count lock. Note: Interpreter and/or 428 * Namespace is not always locked when this function is called. 429 */ 430 LockFlags = AcpiOsAcquireLock (AcpiGbl_ReferenceCountLock); 431 OriginalCount = Object->Common.ReferenceCount; 432 433 /* Perform the reference count action (increment, decrement) */ 434 435 switch (Action) 436 { 437 case REF_INCREMENT: 438 439 NewCount = OriginalCount + 1; 440 Object->Common.ReferenceCount = NewCount; 441 AcpiOsReleaseLock (AcpiGbl_ReferenceCountLock, LockFlags); 442 443 /* The current reference count should never be zero here */ 444 445 if (!OriginalCount) 446 { 447 ACPI_WARNING ((AE_INFO, 448 "Obj %p, Reference Count was zero before increment\n", 449 Object)); 450 } 451 452 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 453 "Obj %p Type %.2X [%s] Refs %.2X [Incremented]\n", 454 Object, Object->Common.Type, 455 AcpiUtGetObjectTypeName (Object), NewCount)); 456 Message = "Incremement"; 457 break; 458 459 case REF_DECREMENT: 460 461 /* The current reference count must be non-zero */ 462 463 if (OriginalCount) 464 { 465 NewCount = OriginalCount - 1; 466 Object->Common.ReferenceCount = NewCount; 467 } 468 469 AcpiOsReleaseLock (AcpiGbl_ReferenceCountLock, LockFlags); 470 471 if (!OriginalCount) 472 { 473 ACPI_WARNING ((AE_INFO, 474 "Obj %p, Reference Count is already zero, cannot decrement\n", 475 Object)); 476 } 477 478 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_ALLOCATIONS, 479 "%s: Obj %p Type %.2X Refs %.2X [Decremented]\n", 480 ACPI_GET_FUNCTION_NAME, Object, Object->Common.Type, NewCount)); 481 482 /* Actually delete the object on a reference count of zero */ 483 484 if (NewCount == 0) 485 { 486 AcpiUtDeleteInternalObj (Object); 487 } 488 Message = "Decrement"; 489 break; 490 491 default: 492 493 AcpiOsReleaseLock (AcpiGbl_ReferenceCountLock, LockFlags); 494 ACPI_ERROR ((AE_INFO, "Unknown Reference Count action (0x%X)", 495 Action)); 496 return; 497 } 498 499 /* 500 * Sanity check the reference count, for debug purposes only. 501 * (A deleted object will have a huge reference count) 502 */ 503 if (NewCount > ACPI_MAX_REFERENCE_COUNT) 504 { 505 ACPI_WARNING ((AE_INFO, 506 "Large Reference Count (0x%X) in object %p, Type=0x%.2X Operation=%s", 507 NewCount, Object, Object->Common.Type, Message)); 508 } 509 } 510 511 512 /******************************************************************************* 513 * 514 * FUNCTION: AcpiUtUpdateObjectReference 515 * 516 * PARAMETERS: Object - Increment ref count for this object 517 * and all sub-objects 518 * Action - Either REF_INCREMENT or REF_DECREMENT 519 * 520 * RETURN: Status 521 * 522 * DESCRIPTION: Increment the object reference count 523 * 524 * Object references are incremented when: 525 * 1) An object is attached to a Node (namespace object) 526 * 2) An object is copied (all subobjects must be incremented) 527 * 528 * Object references are decremented when: 529 * 1) An object is detached from an Node 530 * 531 ******************************************************************************/ 532 533 ACPI_STATUS 534 AcpiUtUpdateObjectReference ( 535 ACPI_OPERAND_OBJECT *Object, 536 UINT16 Action) 537 { 538 ACPI_STATUS Status = AE_OK; 539 ACPI_GENERIC_STATE *StateList = NULL; 540 ACPI_OPERAND_OBJECT *NextObject = NULL; 541 ACPI_OPERAND_OBJECT *PrevObject; 542 ACPI_GENERIC_STATE *State; 543 UINT32 i; 544 545 546 ACPI_FUNCTION_NAME (UtUpdateObjectReference); 547 548 549 while (Object) 550 { 551 /* Make sure that this isn't a namespace handle */ 552 553 if (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED) 554 { 555 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 556 "Object %p is NS handle\n", Object)); 557 return (AE_OK); 558 } 559 560 /* 561 * All sub-objects must have their reference count incremented 562 * also. Different object types have different subobjects. 563 */ 564 switch (Object->Common.Type) 565 { 566 case ACPI_TYPE_DEVICE: 567 case ACPI_TYPE_PROCESSOR: 568 case ACPI_TYPE_POWER: 569 case ACPI_TYPE_THERMAL: 570 /* 571 * Update the notify objects for these types (if present) 572 * Two lists, system and device notify handlers. 573 */ 574 for (i = 0; i < ACPI_NUM_NOTIFY_TYPES; i++) 575 { 576 PrevObject = Object->CommonNotify.NotifyList[i]; 577 while (PrevObject) 578 { 579 NextObject = PrevObject->Notify.Next[i]; 580 AcpiUtUpdateRefCount (PrevObject, Action); 581 PrevObject = NextObject; 582 } 583 } 584 break; 585 586 case ACPI_TYPE_PACKAGE: 587 /* 588 * We must update all the sub-objects of the package, 589 * each of whom may have their own sub-objects. 590 */ 591 for (i = 0; i < Object->Package.Count; i++) 592 { 593 /* 594 * Null package elements are legal and can be simply 595 * ignored. 596 */ 597 NextObject = Object->Package.Elements[i]; 598 if (!NextObject) 599 { 600 continue; 601 } 602 603 switch (NextObject->Common.Type) 604 { 605 case ACPI_TYPE_INTEGER: 606 case ACPI_TYPE_STRING: 607 case ACPI_TYPE_BUFFER: 608 /* 609 * For these very simple sub-objects, we can just 610 * update the reference count here and continue. 611 * Greatly increases performance of this operation. 612 */ 613 AcpiUtUpdateRefCount (NextObject, Action); 614 break; 615 616 default: 617 /* 618 * For complex sub-objects, push them onto the stack 619 * for later processing (this eliminates recursion.) 620 */ 621 Status = AcpiUtCreateUpdateStateAndPush ( 622 NextObject, Action, &StateList); 623 if (ACPI_FAILURE (Status)) 624 { 625 goto ErrorExit; 626 } 627 break; 628 } 629 } 630 NextObject = NULL; 631 break; 632 633 case ACPI_TYPE_BUFFER_FIELD: 634 635 NextObject = Object->BufferField.BufferObj; 636 break; 637 638 case ACPI_TYPE_LOCAL_REGION_FIELD: 639 640 NextObject = Object->Field.RegionObj; 641 break; 642 643 case ACPI_TYPE_LOCAL_BANK_FIELD: 644 645 NextObject = Object->BankField.BankObj; 646 Status = AcpiUtCreateUpdateStateAndPush ( 647 Object->BankField.RegionObj, Action, &StateList); 648 if (ACPI_FAILURE (Status)) 649 { 650 goto ErrorExit; 651 } 652 break; 653 654 case ACPI_TYPE_LOCAL_INDEX_FIELD: 655 656 NextObject = Object->IndexField.IndexObj; 657 Status = AcpiUtCreateUpdateStateAndPush ( 658 Object->IndexField.DataObj, Action, &StateList); 659 if (ACPI_FAILURE (Status)) 660 { 661 goto ErrorExit; 662 } 663 break; 664 665 case ACPI_TYPE_LOCAL_REFERENCE: 666 /* 667 * The target of an Index (a package, string, or buffer) or a named 668 * reference must track changes to the ref count of the index or 669 * target object. 670 */ 671 if ((Object->Reference.Class == ACPI_REFCLASS_INDEX) || 672 (Object->Reference.Class== ACPI_REFCLASS_NAME)) 673 { 674 NextObject = Object->Reference.Object; 675 } 676 break; 677 678 case ACPI_TYPE_REGION: 679 default: 680 681 break; /* No subobjects for all other types */ 682 } 683 684 /* 685 * Now we can update the count in the main object. This can only 686 * happen after we update the sub-objects in case this causes the 687 * main object to be deleted. 688 */ 689 AcpiUtUpdateRefCount (Object, Action); 690 Object = NULL; 691 692 /* Move on to the next object to be updated */ 693 694 if (NextObject) 695 { 696 Object = NextObject; 697 NextObject = NULL; 698 } 699 else if (StateList) 700 { 701 State = AcpiUtPopGenericState (&StateList); 702 Object = State->Update.Object; 703 AcpiUtDeleteGenericState (State); 704 } 705 } 706 707 return (AE_OK); 708 709 710 ErrorExit: 711 712 ACPI_EXCEPTION ((AE_INFO, Status, 713 "Could not update object reference count")); 714 715 /* Free any stacked Update State objects */ 716 717 while (StateList) 718 { 719 State = AcpiUtPopGenericState (&StateList); 720 AcpiUtDeleteGenericState (State); 721 } 722 723 return (Status); 724 } 725 726 727 /******************************************************************************* 728 * 729 * FUNCTION: AcpiUtAddReference 730 * 731 * PARAMETERS: Object - Object whose reference count is to be 732 * incremented 733 * 734 * RETURN: None 735 * 736 * DESCRIPTION: Add one reference to an ACPI object 737 * 738 ******************************************************************************/ 739 740 void 741 AcpiUtAddReference ( 742 ACPI_OPERAND_OBJECT *Object) 743 { 744 745 ACPI_FUNCTION_NAME (UtAddReference); 746 747 748 /* Ensure that we have a valid object */ 749 750 if (!AcpiUtValidInternalObject (Object)) 751 { 752 return; 753 } 754 755 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 756 "Obj %p Current Refs=%X [To Be Incremented]\n", 757 Object, Object->Common.ReferenceCount)); 758 759 /* Increment the reference count */ 760 761 (void) AcpiUtUpdateObjectReference (Object, REF_INCREMENT); 762 return; 763 } 764 765 766 /******************************************************************************* 767 * 768 * FUNCTION: AcpiUtRemoveReference 769 * 770 * PARAMETERS: Object - Object whose ref count will be decremented 771 * 772 * RETURN: None 773 * 774 * DESCRIPTION: Decrement the reference count of an ACPI internal object 775 * 776 ******************************************************************************/ 777 778 void 779 AcpiUtRemoveReference ( 780 ACPI_OPERAND_OBJECT *Object) 781 { 782 783 ACPI_FUNCTION_NAME (UtRemoveReference); 784 785 786 /* 787 * Allow a NULL pointer to be passed in, just ignore it. This saves 788 * each caller from having to check. Also, ignore NS nodes. 789 */ 790 if (!Object || 791 (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED)) 792 793 { 794 return; 795 } 796 797 /* Ensure that we have a valid object */ 798 799 if (!AcpiUtValidInternalObject (Object)) 800 { 801 return; 802 } 803 804 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_ALLOCATIONS, 805 "%s: Obj %p Current Refs=%X [To Be Decremented]\n", 806 ACPI_GET_FUNCTION_NAME, Object, Object->Common.ReferenceCount)); 807 808 /* 809 * Decrement the reference count, and only actually delete the object 810 * if the reference count becomes 0. (Must also decrement the ref count 811 * of all subobjects!) 812 */ 813 (void) AcpiUtUpdateObjectReference (Object, REF_DECREMENT); 814 return; 815 } 816