utdelete.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758
  1. /*******************************************************************************
  2. *
  3. * Module Name: utdelete - object deletion and reference count utilities
  4. *
  5. ******************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2015, Intel Corp.
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions, and the following disclaimer,
  15. * without modification.
  16. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  17. * substantially similar to the "NO WARRANTY" disclaimer below
  18. * ("Disclaimer") and any redistribution must be conditioned upon
  19. * including a substantially similar Disclaimer requirement for further
  20. * binary redistribution.
  21. * 3. Neither the names of the above-listed copyright holders nor the names
  22. * of any contributors may be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * Alternatively, this software may be distributed under the terms of the
  26. * GNU General Public License ("GPL") version 2 as published by the Free
  27. * Software Foundation.
  28. *
  29. * NO WARRANTY
  30. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  31. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  32. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  33. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  34. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  35. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  36. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  38. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  39. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  40. * POSSIBILITY OF SUCH DAMAGES.
  41. */
  42. #include <acpi/acpi.h>
  43. #include "accommon.h"
  44. #include "acinterp.h"
  45. #include "acnamesp.h"
  46. #include "acevents.h"
  47. #define _COMPONENT ACPI_UTILITIES
  48. ACPI_MODULE_NAME("utdelete")
  49. /* Local prototypes */
  50. static void acpi_ut_delete_internal_obj(union acpi_operand_object *object);
  51. static void
  52. acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action);
  53. /*******************************************************************************
  54. *
  55. * FUNCTION: acpi_ut_delete_internal_obj
  56. *
  57. * PARAMETERS: object - Object to be deleted
  58. *
  59. * RETURN: None
  60. *
  61. * DESCRIPTION: Low level object deletion, after reference counts have been
  62. * updated (All reference counts, including sub-objects!)
  63. *
  64. ******************************************************************************/
  65. static void acpi_ut_delete_internal_obj(union acpi_operand_object *object)
  66. {
  67. void *obj_pointer = NULL;
  68. union acpi_operand_object *handler_desc;
  69. union acpi_operand_object *second_desc;
  70. union acpi_operand_object *next_desc;
  71. union acpi_operand_object *start_desc;
  72. union acpi_operand_object **last_obj_ptr;
  73. ACPI_FUNCTION_TRACE_PTR(ut_delete_internal_obj, object);
  74. if (!object) {
  75. return_VOID;
  76. }
  77. /*
  78. * Must delete or free any pointers within the object that are not
  79. * actual ACPI objects (for example, a raw buffer pointer).
  80. */
  81. switch (object->common.type) {
  82. case ACPI_TYPE_STRING:
  83. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  84. "**** String %p, ptr %p\n", object,
  85. object->string.pointer));
  86. /* Free the actual string buffer */
  87. if (!(object->common.flags & AOPOBJ_STATIC_POINTER)) {
  88. /* But only if it is NOT a pointer into an ACPI table */
  89. obj_pointer = object->string.pointer;
  90. }
  91. break;
  92. case ACPI_TYPE_BUFFER:
  93. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  94. "**** Buffer %p, ptr %p\n", object,
  95. object->buffer.pointer));
  96. /* Free the actual buffer */
  97. if (!(object->common.flags & AOPOBJ_STATIC_POINTER)) {
  98. /* But only if it is NOT a pointer into an ACPI table */
  99. obj_pointer = object->buffer.pointer;
  100. }
  101. break;
  102. case ACPI_TYPE_PACKAGE:
  103. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  104. " **** Package of count %X\n",
  105. object->package.count));
  106. /*
  107. * Elements of the package are not handled here, they are deleted
  108. * separately
  109. */
  110. /* Free the (variable length) element pointer array */
  111. obj_pointer = object->package.elements;
  112. break;
  113. /*
  114. * These objects have a possible list of notify handlers.
  115. * Device object also may have a GPE block.
  116. */
  117. case ACPI_TYPE_DEVICE:
  118. if (object->device.gpe_block) {
  119. (void)acpi_ev_delete_gpe_block(object->device.
  120. gpe_block);
  121. }
  122. /*lint -fallthrough */
  123. case ACPI_TYPE_PROCESSOR:
  124. case ACPI_TYPE_THERMAL:
  125. /* Walk the address handler list for this object */
  126. handler_desc = object->common_notify.handler;
  127. while (handler_desc) {
  128. next_desc = handler_desc->address_space.next;
  129. acpi_ut_remove_reference(handler_desc);
  130. handler_desc = next_desc;
  131. }
  132. break;
  133. case ACPI_TYPE_MUTEX:
  134. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  135. "***** Mutex %p, OS Mutex %p\n",
  136. object, object->mutex.os_mutex));
  137. if (object == acpi_gbl_global_lock_mutex) {
  138. /* Global Lock has extra semaphore */
  139. (void)
  140. acpi_os_delete_semaphore
  141. (acpi_gbl_global_lock_semaphore);
  142. acpi_gbl_global_lock_semaphore = NULL;
  143. acpi_os_delete_mutex(object->mutex.os_mutex);
  144. acpi_gbl_global_lock_mutex = NULL;
  145. } else {
  146. acpi_ex_unlink_mutex(object);
  147. acpi_os_delete_mutex(object->mutex.os_mutex);
  148. }
  149. break;
  150. case ACPI_TYPE_EVENT:
  151. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  152. "***** Event %p, OS Semaphore %p\n",
  153. object, object->event.os_semaphore));
  154. (void)acpi_os_delete_semaphore(object->event.os_semaphore);
  155. object->event.os_semaphore = NULL;
  156. break;
  157. case ACPI_TYPE_METHOD:
  158. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  159. "***** Method %p\n", object));
  160. /* Delete the method mutex if it exists */
  161. if (object->method.mutex) {
  162. acpi_os_delete_mutex(object->method.mutex->mutex.
  163. os_mutex);
  164. acpi_ut_delete_object_desc(object->method.mutex);
  165. object->method.mutex = NULL;
  166. }
  167. if (object->method.node) {
  168. object->method.node = NULL;
  169. }
  170. break;
  171. case ACPI_TYPE_REGION:
  172. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  173. "***** Region %p\n", object));
  174. /*
  175. * Update address_range list. However, only permanent regions
  176. * are installed in this list. (Not created within a method)
  177. */
  178. if (!(object->region.node->flags & ANOBJ_TEMPORARY)) {
  179. acpi_ut_remove_address_range(object->region.space_id,
  180. object->region.node);
  181. }
  182. second_desc = acpi_ns_get_secondary_object(object);
  183. if (second_desc) {
  184. /*
  185. * Free the region_context if and only if the handler is one of the
  186. * default handlers -- and therefore, we created the context object
  187. * locally, it was not created by an external caller.
  188. */
  189. handler_desc = object->region.handler;
  190. if (handler_desc) {
  191. next_desc =
  192. handler_desc->address_space.region_list;
  193. start_desc = next_desc;
  194. last_obj_ptr =
  195. &handler_desc->address_space.region_list;
  196. /* Remove the region object from the handler list */
  197. while (next_desc) {
  198. if (next_desc == object) {
  199. *last_obj_ptr =
  200. next_desc->region.next;
  201. break;
  202. }
  203. /* Walk the linked list of handlers */
  204. last_obj_ptr = &next_desc->region.next;
  205. next_desc = next_desc->region.next;
  206. /* Prevent infinite loop if list is corrupted */
  207. if (next_desc == start_desc) {
  208. ACPI_ERROR((AE_INFO,
  209. "Circular region list in address handler object %p",
  210. handler_desc));
  211. return_VOID;
  212. }
  213. }
  214. if (handler_desc->address_space.handler_flags &
  215. ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) {
  216. /* Deactivate region and free region context */
  217. if (handler_desc->address_space.setup) {
  218. (void)handler_desc->
  219. address_space.setup(object,
  220. ACPI_REGION_DEACTIVATE,
  221. handler_desc->
  222. address_space.
  223. context,
  224. &second_desc->
  225. extra.
  226. region_context);
  227. }
  228. }
  229. acpi_ut_remove_reference(handler_desc);
  230. }
  231. /* Now we can free the Extra object */
  232. acpi_ut_delete_object_desc(second_desc);
  233. }
  234. break;
  235. case ACPI_TYPE_BUFFER_FIELD:
  236. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  237. "***** Buffer Field %p\n", object));
  238. second_desc = acpi_ns_get_secondary_object(object);
  239. if (second_desc) {
  240. acpi_ut_delete_object_desc(second_desc);
  241. }
  242. break;
  243. case ACPI_TYPE_LOCAL_BANK_FIELD:
  244. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  245. "***** Bank Field %p\n", object));
  246. second_desc = acpi_ns_get_secondary_object(object);
  247. if (second_desc) {
  248. acpi_ut_delete_object_desc(second_desc);
  249. }
  250. break;
  251. default:
  252. break;
  253. }
  254. /* Free any allocated memory (pointer within the object) found above */
  255. if (obj_pointer) {
  256. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  257. "Deleting Object Subptr %p\n", obj_pointer));
  258. ACPI_FREE(obj_pointer);
  259. }
  260. /* Now the object can be safely deleted */
  261. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Deleting Object %p [%s]\n",
  262. object, acpi_ut_get_object_type_name(object)));
  263. acpi_ut_delete_object_desc(object);
  264. return_VOID;
  265. }
  266. /*******************************************************************************
  267. *
  268. * FUNCTION: acpi_ut_delete_internal_object_list
  269. *
  270. * PARAMETERS: obj_list - Pointer to the list to be deleted
  271. *
  272. * RETURN: None
  273. *
  274. * DESCRIPTION: This function deletes an internal object list, including both
  275. * simple objects and package objects
  276. *
  277. ******************************************************************************/
  278. void acpi_ut_delete_internal_object_list(union acpi_operand_object **obj_list)
  279. {
  280. union acpi_operand_object **internal_obj;
  281. ACPI_FUNCTION_ENTRY();
  282. /* Walk the null-terminated internal list */
  283. for (internal_obj = obj_list; *internal_obj; internal_obj++) {
  284. acpi_ut_remove_reference(*internal_obj);
  285. }
  286. /* Free the combined parameter pointer list and object array */
  287. ACPI_FREE(obj_list);
  288. return;
  289. }
  290. /*******************************************************************************
  291. *
  292. * FUNCTION: acpi_ut_update_ref_count
  293. *
  294. * PARAMETERS: object - Object whose ref count is to be updated
  295. * action - What to do (REF_INCREMENT or REF_DECREMENT)
  296. *
  297. * RETURN: None. Sets new reference count within the object
  298. *
  299. * DESCRIPTION: Modify the reference count for an internal acpi object
  300. *
  301. ******************************************************************************/
  302. static void
  303. acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action)
  304. {
  305. u16 original_count;
  306. u16 new_count = 0;
  307. acpi_cpu_flags lock_flags;
  308. ACPI_FUNCTION_NAME(ut_update_ref_count);
  309. if (!object) {
  310. return;
  311. }
  312. /*
  313. * Always get the reference count lock. Note: Interpreter and/or
  314. * Namespace is not always locked when this function is called.
  315. */
  316. lock_flags = acpi_os_acquire_lock(acpi_gbl_reference_count_lock);
  317. original_count = object->common.reference_count;
  318. /* Perform the reference count action (increment, decrement) */
  319. switch (action) {
  320. case REF_INCREMENT:
  321. new_count = original_count + 1;
  322. object->common.reference_count = new_count;
  323. acpi_os_release_lock(acpi_gbl_reference_count_lock, lock_flags);
  324. /* The current reference count should never be zero here */
  325. if (!original_count) {
  326. ACPI_WARNING((AE_INFO,
  327. "Obj %p, Reference Count was zero before increment\n",
  328. object));
  329. }
  330. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  331. "Obj %p Type %.2X Refs %.2X [Incremented]\n",
  332. object, object->common.type, new_count));
  333. break;
  334. case REF_DECREMENT:
  335. /* The current reference count must be non-zero */
  336. if (original_count) {
  337. new_count = original_count - 1;
  338. object->common.reference_count = new_count;
  339. }
  340. acpi_os_release_lock(acpi_gbl_reference_count_lock, lock_flags);
  341. if (!original_count) {
  342. ACPI_WARNING((AE_INFO,
  343. "Obj %p, Reference Count is already zero, cannot decrement\n",
  344. object));
  345. }
  346. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  347. "Obj %p Type %.2X Refs %.2X [Decremented]\n",
  348. object, object->common.type, new_count));
  349. /* Actually delete the object on a reference count of zero */
  350. if (new_count == 0) {
  351. acpi_ut_delete_internal_obj(object);
  352. }
  353. break;
  354. default:
  355. acpi_os_release_lock(acpi_gbl_reference_count_lock, lock_flags);
  356. ACPI_ERROR((AE_INFO, "Unknown Reference Count action (0x%X)",
  357. action));
  358. return;
  359. }
  360. /*
  361. * Sanity check the reference count, for debug purposes only.
  362. * (A deleted object will have a huge reference count)
  363. */
  364. if (new_count > ACPI_MAX_REFERENCE_COUNT) {
  365. ACPI_WARNING((AE_INFO,
  366. "Large Reference Count (0x%X) in object %p, Type=0x%.2X",
  367. new_count, object, object->common.type));
  368. }
  369. }
  370. /*******************************************************************************
  371. *
  372. * FUNCTION: acpi_ut_update_object_reference
  373. *
  374. * PARAMETERS: object - Increment ref count for this object
  375. * and all sub-objects
  376. * action - Either REF_INCREMENT or REF_DECREMENT
  377. *
  378. * RETURN: Status
  379. *
  380. * DESCRIPTION: Increment the object reference count
  381. *
  382. * Object references are incremented when:
  383. * 1) An object is attached to a Node (namespace object)
  384. * 2) An object is copied (all subobjects must be incremented)
  385. *
  386. * Object references are decremented when:
  387. * 1) An object is detached from an Node
  388. *
  389. ******************************************************************************/
  390. acpi_status
  391. acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
  392. {
  393. acpi_status status = AE_OK;
  394. union acpi_generic_state *state_list = NULL;
  395. union acpi_operand_object *next_object = NULL;
  396. union acpi_operand_object *prev_object;
  397. union acpi_generic_state *state;
  398. u32 i;
  399. ACPI_FUNCTION_NAME(ut_update_object_reference);
  400. while (object) {
  401. /* Make sure that this isn't a namespace handle */
  402. if (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED) {
  403. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  404. "Object %p is NS handle\n", object));
  405. return (AE_OK);
  406. }
  407. /*
  408. * All sub-objects must have their reference count incremented also.
  409. * Different object types have different subobjects.
  410. */
  411. switch (object->common.type) {
  412. case ACPI_TYPE_DEVICE:
  413. case ACPI_TYPE_PROCESSOR:
  414. case ACPI_TYPE_POWER:
  415. case ACPI_TYPE_THERMAL:
  416. /*
  417. * Update the notify objects for these types (if present)
  418. * Two lists, system and device notify handlers.
  419. */
  420. for (i = 0; i < ACPI_NUM_NOTIFY_TYPES; i++) {
  421. prev_object =
  422. object->common_notify.notify_list[i];
  423. while (prev_object) {
  424. next_object =
  425. prev_object->notify.next[i];
  426. acpi_ut_update_ref_count(prev_object,
  427. action);
  428. prev_object = next_object;
  429. }
  430. }
  431. break;
  432. case ACPI_TYPE_PACKAGE:
  433. /*
  434. * We must update all the sub-objects of the package,
  435. * each of whom may have their own sub-objects.
  436. */
  437. for (i = 0; i < object->package.count; i++) {
  438. /*
  439. * Null package elements are legal and can be simply
  440. * ignored.
  441. */
  442. next_object = object->package.elements[i];
  443. if (!next_object) {
  444. continue;
  445. }
  446. switch (next_object->common.type) {
  447. case ACPI_TYPE_INTEGER:
  448. case ACPI_TYPE_STRING:
  449. case ACPI_TYPE_BUFFER:
  450. /*
  451. * For these very simple sub-objects, we can just
  452. * update the reference count here and continue.
  453. * Greatly increases performance of this operation.
  454. */
  455. acpi_ut_update_ref_count(next_object,
  456. action);
  457. break;
  458. default:
  459. /*
  460. * For complex sub-objects, push them onto the stack
  461. * for later processing (this eliminates recursion.)
  462. */
  463. status =
  464. acpi_ut_create_update_state_and_push
  465. (next_object, action, &state_list);
  466. if (ACPI_FAILURE(status)) {
  467. goto error_exit;
  468. }
  469. break;
  470. }
  471. }
  472. next_object = NULL;
  473. break;
  474. case ACPI_TYPE_BUFFER_FIELD:
  475. next_object = object->buffer_field.buffer_obj;
  476. break;
  477. case ACPI_TYPE_LOCAL_REGION_FIELD:
  478. next_object = object->field.region_obj;
  479. break;
  480. case ACPI_TYPE_LOCAL_BANK_FIELD:
  481. next_object = object->bank_field.bank_obj;
  482. status =
  483. acpi_ut_create_update_state_and_push(object->
  484. bank_field.
  485. region_obj,
  486. action,
  487. &state_list);
  488. if (ACPI_FAILURE(status)) {
  489. goto error_exit;
  490. }
  491. break;
  492. case ACPI_TYPE_LOCAL_INDEX_FIELD:
  493. next_object = object->index_field.index_obj;
  494. status =
  495. acpi_ut_create_update_state_and_push(object->
  496. index_field.
  497. data_obj,
  498. action,
  499. &state_list);
  500. if (ACPI_FAILURE(status)) {
  501. goto error_exit;
  502. }
  503. break;
  504. case ACPI_TYPE_LOCAL_REFERENCE:
  505. /*
  506. * The target of an Index (a package, string, or buffer) or a named
  507. * reference must track changes to the ref count of the index or
  508. * target object.
  509. */
  510. if ((object->reference.class == ACPI_REFCLASS_INDEX) ||
  511. (object->reference.class == ACPI_REFCLASS_NAME)) {
  512. next_object = object->reference.object;
  513. }
  514. break;
  515. case ACPI_TYPE_REGION:
  516. default:
  517. break; /* No subobjects for all other types */
  518. }
  519. /*
  520. * Now we can update the count in the main object. This can only
  521. * happen after we update the sub-objects in case this causes the
  522. * main object to be deleted.
  523. */
  524. acpi_ut_update_ref_count(object, action);
  525. object = NULL;
  526. /* Move on to the next object to be updated */
  527. if (next_object) {
  528. object = next_object;
  529. next_object = NULL;
  530. } else if (state_list) {
  531. state = acpi_ut_pop_generic_state(&state_list);
  532. object = state->update.object;
  533. acpi_ut_delete_generic_state(state);
  534. }
  535. }
  536. return (AE_OK);
  537. error_exit:
  538. ACPI_EXCEPTION((AE_INFO, status,
  539. "Could not update object reference count"));
  540. /* Free any stacked Update State objects */
  541. while (state_list) {
  542. state = acpi_ut_pop_generic_state(&state_list);
  543. acpi_ut_delete_generic_state(state);
  544. }
  545. return (status);
  546. }
  547. /*******************************************************************************
  548. *
  549. * FUNCTION: acpi_ut_add_reference
  550. *
  551. * PARAMETERS: object - Object whose reference count is to be
  552. * incremented
  553. *
  554. * RETURN: None
  555. *
  556. * DESCRIPTION: Add one reference to an ACPI object
  557. *
  558. ******************************************************************************/
  559. void acpi_ut_add_reference(union acpi_operand_object *object)
  560. {
  561. ACPI_FUNCTION_NAME(ut_add_reference);
  562. /* Ensure that we have a valid object */
  563. if (!acpi_ut_valid_internal_object(object)) {
  564. return;
  565. }
  566. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  567. "Obj %p Current Refs=%X [To Be Incremented]\n",
  568. object, object->common.reference_count));
  569. /* Increment the reference count */
  570. (void)acpi_ut_update_object_reference(object, REF_INCREMENT);
  571. return;
  572. }
  573. /*******************************************************************************
  574. *
  575. * FUNCTION: acpi_ut_remove_reference
  576. *
  577. * PARAMETERS: object - Object whose ref count will be decremented
  578. *
  579. * RETURN: None
  580. *
  581. * DESCRIPTION: Decrement the reference count of an ACPI internal object
  582. *
  583. ******************************************************************************/
  584. void acpi_ut_remove_reference(union acpi_operand_object *object)
  585. {
  586. ACPI_FUNCTION_NAME(ut_remove_reference);
  587. /*
  588. * Allow a NULL pointer to be passed in, just ignore it. This saves
  589. * each caller from having to check. Also, ignore NS nodes.
  590. */
  591. if (!object ||
  592. (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED)) {
  593. return;
  594. }
  595. /* Ensure that we have a valid object */
  596. if (!acpi_ut_valid_internal_object(object)) {
  597. return;
  598. }
  599. ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
  600. "Obj %p Current Refs=%X [To Be Decremented]\n",
  601. object, object->common.reference_count));
  602. /*
  603. * Decrement the reference count, and only actually delete the object
  604. * if the reference count becomes 0. (Must also decrement the ref count
  605. * of all subobjects!)
  606. */
  607. (void)acpi_ut_update_object_reference(object, REF_DECREMENT);
  608. return;
  609. }