dswstate.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  1. // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
  2. /******************************************************************************
  3. *
  4. * Module Name: dswstate - Dispatcher parse tree walk management routines
  5. *
  6. * Copyright (C) 2000 - 2022, Intel Corp.
  7. *
  8. *****************************************************************************/
  9. #include <acpi/acpi.h>
  10. #include "accommon.h"
  11. #include "acparser.h"
  12. #include "acdispat.h"
  13. #include "acnamesp.h"
  14. #define _COMPONENT ACPI_DISPATCHER
  15. ACPI_MODULE_NAME("dswstate")
  16. /* Local prototypes */
  17. static acpi_status
  18. acpi_ds_result_stack_push(struct acpi_walk_state *walk_state);
  19. static acpi_status acpi_ds_result_stack_pop(struct acpi_walk_state *walk_state);
  20. /*******************************************************************************
  21. *
  22. * FUNCTION: acpi_ds_result_pop
  23. *
  24. * PARAMETERS: object - Where to return the popped object
  25. * walk_state - Current Walk state
  26. *
  27. * RETURN: Status
  28. *
  29. * DESCRIPTION: Pop an object off the top of this walk's result stack
  30. *
  31. ******************************************************************************/
  32. acpi_status
  33. acpi_ds_result_pop(union acpi_operand_object **object,
  34. struct acpi_walk_state *walk_state)
  35. {
  36. u32 index;
  37. union acpi_generic_state *state;
  38. acpi_status status;
  39. ACPI_FUNCTION_NAME(ds_result_pop);
  40. state = walk_state->results;
  41. /* Incorrect state of result stack */
  42. if (state && !walk_state->result_count) {
  43. ACPI_ERROR((AE_INFO, "No results on result stack"));
  44. return (AE_AML_INTERNAL);
  45. }
  46. if (!state && walk_state->result_count) {
  47. ACPI_ERROR((AE_INFO, "No result state for result stack"));
  48. return (AE_AML_INTERNAL);
  49. }
  50. /* Empty result stack */
  51. if (!state) {
  52. ACPI_ERROR((AE_INFO, "Result stack is empty! State=%p",
  53. walk_state));
  54. return (AE_AML_NO_RETURN_VALUE);
  55. }
  56. /* Return object of the top element and clean that top element result stack */
  57. walk_state->result_count--;
  58. index = (u32)walk_state->result_count % ACPI_RESULTS_FRAME_OBJ_NUM;
  59. *object = state->results.obj_desc[index];
  60. if (!*object) {
  61. ACPI_ERROR((AE_INFO,
  62. "No result objects on result stack, State=%p",
  63. walk_state));
  64. return (AE_AML_NO_RETURN_VALUE);
  65. }
  66. state->results.obj_desc[index] = NULL;
  67. if (index == 0) {
  68. status = acpi_ds_result_stack_pop(walk_state);
  69. if (ACPI_FAILURE(status)) {
  70. return (status);
  71. }
  72. }
  73. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  74. "Obj=%p [%s] Index=%X State=%p Num=%X\n", *object,
  75. acpi_ut_get_object_type_name(*object),
  76. index, walk_state, walk_state->result_count));
  77. return (AE_OK);
  78. }
  79. /*******************************************************************************
  80. *
  81. * FUNCTION: acpi_ds_result_push
  82. *
  83. * PARAMETERS: object - Where to return the popped object
  84. * walk_state - Current Walk state
  85. *
  86. * RETURN: Status
  87. *
  88. * DESCRIPTION: Push an object onto the current result stack
  89. *
  90. ******************************************************************************/
  91. acpi_status
  92. acpi_ds_result_push(union acpi_operand_object *object,
  93. struct acpi_walk_state *walk_state)
  94. {
  95. union acpi_generic_state *state;
  96. acpi_status status;
  97. u32 index;
  98. ACPI_FUNCTION_NAME(ds_result_push);
  99. if (walk_state->result_count > walk_state->result_size) {
  100. ACPI_ERROR((AE_INFO, "Result stack is full"));
  101. return (AE_AML_INTERNAL);
  102. } else if (walk_state->result_count == walk_state->result_size) {
  103. /* Extend the result stack */
  104. status = acpi_ds_result_stack_push(walk_state);
  105. if (ACPI_FAILURE(status)) {
  106. ACPI_ERROR((AE_INFO,
  107. "Failed to extend the result stack"));
  108. return (status);
  109. }
  110. }
  111. if (!(walk_state->result_count < walk_state->result_size)) {
  112. ACPI_ERROR((AE_INFO, "No free elements in result stack"));
  113. return (AE_AML_INTERNAL);
  114. }
  115. state = walk_state->results;
  116. if (!state) {
  117. ACPI_ERROR((AE_INFO, "No result stack frame during push"));
  118. return (AE_AML_INTERNAL);
  119. }
  120. if (!object) {
  121. ACPI_ERROR((AE_INFO,
  122. "Null Object! Obj=%p State=%p Num=%u",
  123. object, walk_state, walk_state->result_count));
  124. return (AE_BAD_PARAMETER);
  125. }
  126. /* Assign the address of object to the top free element of result stack */
  127. index = (u32)walk_state->result_count % ACPI_RESULTS_FRAME_OBJ_NUM;
  128. state->results.obj_desc[index] = object;
  129. walk_state->result_count++;
  130. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p [%s] State=%p Num=%X Cur=%X\n",
  131. object,
  132. acpi_ut_get_object_type_name((union
  133. acpi_operand_object *)
  134. object), walk_state,
  135. walk_state->result_count,
  136. walk_state->current_result));
  137. return (AE_OK);
  138. }
  139. /*******************************************************************************
  140. *
  141. * FUNCTION: acpi_ds_result_stack_push
  142. *
  143. * PARAMETERS: walk_state - Current Walk state
  144. *
  145. * RETURN: Status
  146. *
  147. * DESCRIPTION: Push an object onto the walk_state result stack
  148. *
  149. ******************************************************************************/
  150. static acpi_status acpi_ds_result_stack_push(struct acpi_walk_state *walk_state)
  151. {
  152. union acpi_generic_state *state;
  153. ACPI_FUNCTION_NAME(ds_result_stack_push);
  154. /* Check for stack overflow */
  155. if (((u32) walk_state->result_size + ACPI_RESULTS_FRAME_OBJ_NUM) >
  156. ACPI_RESULTS_OBJ_NUM_MAX) {
  157. ACPI_ERROR((AE_INFO, "Result stack overflow: State=%p Num=%u",
  158. walk_state, walk_state->result_size));
  159. return (AE_STACK_OVERFLOW);
  160. }
  161. state = acpi_ut_create_generic_state();
  162. if (!state) {
  163. return (AE_NO_MEMORY);
  164. }
  165. state->common.descriptor_type = ACPI_DESC_TYPE_STATE_RESULT;
  166. acpi_ut_push_generic_state(&walk_state->results, state);
  167. /* Increase the length of the result stack by the length of frame */
  168. walk_state->result_size += ACPI_RESULTS_FRAME_OBJ_NUM;
  169. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Results=%p State=%p\n",
  170. state, walk_state));
  171. return (AE_OK);
  172. }
  173. /*******************************************************************************
  174. *
  175. * FUNCTION: acpi_ds_result_stack_pop
  176. *
  177. * PARAMETERS: walk_state - Current Walk state
  178. *
  179. * RETURN: Status
  180. *
  181. * DESCRIPTION: Pop an object off of the walk_state result stack
  182. *
  183. ******************************************************************************/
  184. static acpi_status acpi_ds_result_stack_pop(struct acpi_walk_state *walk_state)
  185. {
  186. union acpi_generic_state *state;
  187. ACPI_FUNCTION_NAME(ds_result_stack_pop);
  188. /* Check for stack underflow */
  189. if (walk_state->results == NULL) {
  190. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  191. "Result stack underflow - State=%p\n",
  192. walk_state));
  193. return (AE_AML_NO_OPERAND);
  194. }
  195. if (walk_state->result_size < ACPI_RESULTS_FRAME_OBJ_NUM) {
  196. ACPI_ERROR((AE_INFO, "Insufficient result stack size"));
  197. return (AE_AML_INTERNAL);
  198. }
  199. state = acpi_ut_pop_generic_state(&walk_state->results);
  200. acpi_ut_delete_generic_state(state);
  201. /* Decrease the length of result stack by the length of frame */
  202. walk_state->result_size -= ACPI_RESULTS_FRAME_OBJ_NUM;
  203. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  204. "Result=%p RemainingResults=%X State=%p\n",
  205. state, walk_state->result_count, walk_state));
  206. return (AE_OK);
  207. }
  208. /*******************************************************************************
  209. *
  210. * FUNCTION: acpi_ds_obj_stack_push
  211. *
  212. * PARAMETERS: object - Object to push
  213. * walk_state - Current Walk state
  214. *
  215. * RETURN: Status
  216. *
  217. * DESCRIPTION: Push an object onto this walk's object/operand stack
  218. *
  219. ******************************************************************************/
  220. acpi_status
  221. acpi_ds_obj_stack_push(void *object, struct acpi_walk_state *walk_state)
  222. {
  223. ACPI_FUNCTION_NAME(ds_obj_stack_push);
  224. /* Check for stack overflow */
  225. if (walk_state->num_operands >= ACPI_OBJ_NUM_OPERANDS) {
  226. ACPI_ERROR((AE_INFO,
  227. "Object stack overflow! Obj=%p State=%p #Ops=%u",
  228. object, walk_state, walk_state->num_operands));
  229. return (AE_STACK_OVERFLOW);
  230. }
  231. /* Put the object onto the stack */
  232. walk_state->operands[walk_state->operand_index] = object;
  233. walk_state->num_operands++;
  234. /* For the usual order of filling the operand stack */
  235. walk_state->operand_index++;
  236. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n",
  237. object,
  238. acpi_ut_get_object_type_name((union
  239. acpi_operand_object *)
  240. object), walk_state,
  241. walk_state->num_operands));
  242. return (AE_OK);
  243. }
  244. /*******************************************************************************
  245. *
  246. * FUNCTION: acpi_ds_obj_stack_pop
  247. *
  248. * PARAMETERS: pop_count - Number of objects/entries to pop
  249. * walk_state - Current Walk state
  250. *
  251. * RETURN: Status
  252. *
  253. * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT
  254. * deleted by this routine.
  255. *
  256. ******************************************************************************/
  257. acpi_status
  258. acpi_ds_obj_stack_pop(u32 pop_count, struct acpi_walk_state *walk_state)
  259. {
  260. u32 i;
  261. ACPI_FUNCTION_NAME(ds_obj_stack_pop);
  262. for (i = 0; i < pop_count; i++) {
  263. /* Check for stack underflow */
  264. if (walk_state->num_operands == 0) {
  265. ACPI_ERROR((AE_INFO,
  266. "Object stack underflow! Count=%X State=%p #Ops=%u",
  267. pop_count, walk_state,
  268. walk_state->num_operands));
  269. return (AE_STACK_UNDERFLOW);
  270. }
  271. /* Just set the stack entry to null */
  272. walk_state->num_operands--;
  273. walk_state->operands[walk_state->num_operands] = NULL;
  274. }
  275. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%u\n",
  276. pop_count, walk_state, walk_state->num_operands));
  277. return (AE_OK);
  278. }
  279. /*******************************************************************************
  280. *
  281. * FUNCTION: acpi_ds_obj_stack_pop_and_delete
  282. *
  283. * PARAMETERS: pop_count - Number of objects/entries to pop
  284. * walk_state - Current Walk state
  285. *
  286. * RETURN: Status
  287. *
  288. * DESCRIPTION: Pop this walk's object stack and delete each object that is
  289. * popped off.
  290. *
  291. ******************************************************************************/
  292. void
  293. acpi_ds_obj_stack_pop_and_delete(u32 pop_count,
  294. struct acpi_walk_state *walk_state)
  295. {
  296. s32 i;
  297. union acpi_operand_object *obj_desc;
  298. ACPI_FUNCTION_NAME(ds_obj_stack_pop_and_delete);
  299. if (pop_count == 0) {
  300. return;
  301. }
  302. for (i = (s32)pop_count - 1; i >= 0; i--) {
  303. if (walk_state->num_operands == 0) {
  304. return;
  305. }
  306. /* Pop the stack and delete an object if present in this stack entry */
  307. walk_state->num_operands--;
  308. obj_desc = walk_state->operands[i];
  309. if (obj_desc) {
  310. acpi_ut_remove_reference(walk_state->operands[i]);
  311. walk_state->operands[i] = NULL;
  312. }
  313. }
  314. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n",
  315. pop_count, walk_state, walk_state->num_operands));
  316. }
  317. /*******************************************************************************
  318. *
  319. * FUNCTION: acpi_ds_get_current_walk_state
  320. *
  321. * PARAMETERS: thread - Get current active state for this Thread
  322. *
  323. * RETURN: Pointer to the current walk state
  324. *
  325. * DESCRIPTION: Get the walk state that is at the head of the list (the "current"
  326. * walk state.)
  327. *
  328. ******************************************************************************/
  329. struct acpi_walk_state *acpi_ds_get_current_walk_state(struct acpi_thread_state
  330. *thread)
  331. {
  332. ACPI_FUNCTION_NAME(ds_get_current_walk_state);
  333. if (!thread) {
  334. return (NULL);
  335. }
  336. ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "Current WalkState %p\n",
  337. thread->walk_state_list));
  338. return (thread->walk_state_list);
  339. }
  340. /*******************************************************************************
  341. *
  342. * FUNCTION: acpi_ds_push_walk_state
  343. *
  344. * PARAMETERS: walk_state - State to push
  345. * thread - Thread state object
  346. *
  347. * RETURN: None
  348. *
  349. * DESCRIPTION: Place the Thread state at the head of the state list
  350. *
  351. ******************************************************************************/
  352. void
  353. acpi_ds_push_walk_state(struct acpi_walk_state *walk_state,
  354. struct acpi_thread_state *thread)
  355. {
  356. ACPI_FUNCTION_TRACE(ds_push_walk_state);
  357. walk_state->next = thread->walk_state_list;
  358. thread->walk_state_list = walk_state;
  359. return_VOID;
  360. }
  361. /*******************************************************************************
  362. *
  363. * FUNCTION: acpi_ds_pop_walk_state
  364. *
  365. * PARAMETERS: thread - Current thread state
  366. *
  367. * RETURN: A walk_state object popped from the thread's stack
  368. *
  369. * DESCRIPTION: Remove and return the walkstate object that is at the head of
  370. * the walk stack for the given walk list. NULL indicates that
  371. * the list is empty.
  372. *
  373. ******************************************************************************/
  374. struct acpi_walk_state *acpi_ds_pop_walk_state(struct acpi_thread_state *thread)
  375. {
  376. struct acpi_walk_state *walk_state;
  377. ACPI_FUNCTION_TRACE(ds_pop_walk_state);
  378. walk_state = thread->walk_state_list;
  379. if (walk_state) {
  380. /* Next walk state becomes the current walk state */
  381. thread->walk_state_list = walk_state->next;
  382. /*
  383. * Don't clear the NEXT field, this serves as an indicator
  384. * that there is a parent WALK STATE
  385. * Do Not: walk_state->Next = NULL;
  386. */
  387. }
  388. return_PTR(walk_state);
  389. }
  390. /*******************************************************************************
  391. *
  392. * FUNCTION: acpi_ds_create_walk_state
  393. *
  394. * PARAMETERS: owner_id - ID for object creation
  395. * origin - Starting point for this walk
  396. * method_desc - Method object
  397. * thread - Current thread state
  398. *
  399. * RETURN: Pointer to the new walk state.
  400. *
  401. * DESCRIPTION: Allocate and initialize a new walk state. The current walk
  402. * state is set to this new state.
  403. *
  404. ******************************************************************************/
  405. struct acpi_walk_state *acpi_ds_create_walk_state(acpi_owner_id owner_id,
  406. union acpi_parse_object
  407. *origin,
  408. union acpi_operand_object
  409. *method_desc,
  410. struct acpi_thread_state
  411. *thread)
  412. {
  413. struct acpi_walk_state *walk_state;
  414. ACPI_FUNCTION_TRACE(ds_create_walk_state);
  415. walk_state = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_walk_state));
  416. if (!walk_state) {
  417. return_PTR(NULL);
  418. }
  419. walk_state->descriptor_type = ACPI_DESC_TYPE_WALK;
  420. walk_state->method_desc = method_desc;
  421. walk_state->owner_id = owner_id;
  422. walk_state->origin = origin;
  423. walk_state->thread = thread;
  424. walk_state->parser_state.start_op = origin;
  425. /* Init the method args/local */
  426. #ifndef ACPI_CONSTANT_EVAL_ONLY
  427. acpi_ds_method_data_init(walk_state);
  428. #endif
  429. /* Put the new state at the head of the walk list */
  430. if (thread) {
  431. acpi_ds_push_walk_state(walk_state, thread);
  432. }
  433. return_PTR(walk_state);
  434. }
  435. /*******************************************************************************
  436. *
  437. * FUNCTION: acpi_ds_init_aml_walk
  438. *
  439. * PARAMETERS: walk_state - New state to be initialized
  440. * op - Current parse op
  441. * method_node - Control method NS node, if any
  442. * aml_start - Start of AML
  443. * aml_length - Length of AML
  444. * info - Method info block (params, etc.)
  445. * pass_number - 1, 2, or 3
  446. *
  447. * RETURN: Status
  448. *
  449. * DESCRIPTION: Initialize a walk state for a pass 1 or 2 parse tree walk
  450. *
  451. ******************************************************************************/
  452. acpi_status
  453. acpi_ds_init_aml_walk(struct acpi_walk_state *walk_state,
  454. union acpi_parse_object *op,
  455. struct acpi_namespace_node *method_node,
  456. u8 * aml_start,
  457. u32 aml_length,
  458. struct acpi_evaluate_info *info, u8 pass_number)
  459. {
  460. acpi_status status;
  461. struct acpi_parse_state *parser_state = &walk_state->parser_state;
  462. union acpi_parse_object *extra_op;
  463. ACPI_FUNCTION_TRACE(ds_init_aml_walk);
  464. walk_state->parser_state.aml =
  465. walk_state->parser_state.aml_start =
  466. walk_state->parser_state.aml_end =
  467. walk_state->parser_state.pkg_end = aml_start;
  468. /* Avoid undefined behavior: applying zero offset to null pointer */
  469. if (aml_length != 0) {
  470. walk_state->parser_state.aml_end += aml_length;
  471. walk_state->parser_state.pkg_end += aml_length;
  472. }
  473. /* The next_op of the next_walk will be the beginning of the method */
  474. walk_state->next_op = NULL;
  475. walk_state->pass_number = pass_number;
  476. if (info) {
  477. walk_state->params = info->parameters;
  478. walk_state->caller_return_desc = &info->return_object;
  479. }
  480. status = acpi_ps_init_scope(&walk_state->parser_state, op);
  481. if (ACPI_FAILURE(status)) {
  482. return_ACPI_STATUS(status);
  483. }
  484. if (method_node) {
  485. walk_state->parser_state.start_node = method_node;
  486. walk_state->walk_type = ACPI_WALK_METHOD;
  487. walk_state->method_node = method_node;
  488. walk_state->method_desc =
  489. acpi_ns_get_attached_object(method_node);
  490. /* Push start scope on scope stack and make it current */
  491. status =
  492. acpi_ds_scope_stack_push(method_node, ACPI_TYPE_METHOD,
  493. walk_state);
  494. if (ACPI_FAILURE(status)) {
  495. return_ACPI_STATUS(status);
  496. }
  497. /* Init the method arguments */
  498. status = acpi_ds_method_data_init_args(walk_state->params,
  499. ACPI_METHOD_NUM_ARGS,
  500. walk_state);
  501. if (ACPI_FAILURE(status)) {
  502. return_ACPI_STATUS(status);
  503. }
  504. } else {
  505. /*
  506. * Setup the current scope.
  507. * Find a Named Op that has a namespace node associated with it.
  508. * search upwards from this Op. Current scope is the first
  509. * Op with a namespace node.
  510. */
  511. extra_op = parser_state->start_op;
  512. while (extra_op && !extra_op->common.node) {
  513. extra_op = extra_op->common.parent;
  514. }
  515. if (!extra_op) {
  516. parser_state->start_node = NULL;
  517. } else {
  518. parser_state->start_node = extra_op->common.node;
  519. }
  520. if (parser_state->start_node) {
  521. /* Push start scope on scope stack and make it current */
  522. status =
  523. acpi_ds_scope_stack_push(parser_state->start_node,
  524. parser_state->start_node->
  525. type, walk_state);
  526. if (ACPI_FAILURE(status)) {
  527. return_ACPI_STATUS(status);
  528. }
  529. }
  530. }
  531. status = acpi_ds_init_callbacks(walk_state, pass_number);
  532. return_ACPI_STATUS(status);
  533. }
  534. /*******************************************************************************
  535. *
  536. * FUNCTION: acpi_ds_delete_walk_state
  537. *
  538. * PARAMETERS: walk_state - State to delete
  539. *
  540. * RETURN: Status
  541. *
  542. * DESCRIPTION: Delete a walk state including all internal data structures
  543. *
  544. ******************************************************************************/
  545. void acpi_ds_delete_walk_state(struct acpi_walk_state *walk_state)
  546. {
  547. union acpi_generic_state *state;
  548. ACPI_FUNCTION_TRACE_PTR(ds_delete_walk_state, walk_state);
  549. if (!walk_state) {
  550. return_VOID;
  551. }
  552. if (walk_state->descriptor_type != ACPI_DESC_TYPE_WALK) {
  553. ACPI_ERROR((AE_INFO, "%p is not a valid walk state",
  554. walk_state));
  555. return_VOID;
  556. }
  557. /* There should not be any open scopes */
  558. if (walk_state->parser_state.scope) {
  559. ACPI_ERROR((AE_INFO, "%p walk still has a scope list",
  560. walk_state));
  561. acpi_ps_cleanup_scope(&walk_state->parser_state);
  562. }
  563. /* Always must free any linked control states */
  564. while (walk_state->control_state) {
  565. state = walk_state->control_state;
  566. walk_state->control_state = state->common.next;
  567. acpi_ut_delete_generic_state(state);
  568. }
  569. /* Always must free any linked parse states */
  570. while (walk_state->scope_info) {
  571. state = walk_state->scope_info;
  572. walk_state->scope_info = state->common.next;
  573. acpi_ut_delete_generic_state(state);
  574. }
  575. /* Always must free any stacked result states */
  576. while (walk_state->results) {
  577. state = walk_state->results;
  578. walk_state->results = state->common.next;
  579. acpi_ut_delete_generic_state(state);
  580. }
  581. ACPI_FREE(walk_state);
  582. return_VOID;
  583. }