https://bugzilla.kernel.org/show_bug.cgi?id=189131

            Bug ID: 189131
           Summary: Function acpi_ns_convert_to_reference() returns
                    improper value on failures
           Product: ACPI
           Version: 2.5
    Kernel Version: linux-4.9-rc6
          Hardware: All
                OS: Linux
              Tree: Mainline
            Status: NEW
          Severity: normal
          Priority: P1
         Component: ACPICA-Core
          Assignee: [email protected]
          Reporter: [email protected]
        Regression: No

Function acpi_ns_convert_to_reference() is defined in file
drivers/acpi/acpica/nsconvert.c. Its comment says "RETURN:      Status. AE_OK
if conversion was successful". However, it may return "AE_OK" even on failures.
The inconsistence between return value and execution status may misled the
callers of acpi_ns_convert_to_reference(), resulting in unexpected bugs. I
think it is better to use "return_ACPI_STATUS(status);" rather than "return
(AE_OK);" at line 522. Codes related to this bug are summarised as below.

450
/*******************************************************************************
451  *
452  * FUNCTION:    acpi_ns_convert_to_reference
453  *
454  * PARAMETERS:  scope               - Namespace node for the method/object
455  *              original_object     - Object to be converted
456  *              return_object       - Where the new converted object is
returned
457  *
458  * RETURN:      Status. AE_OK if conversion was successful
459  *
460  * DESCRIPTION: Attempt to convert a Integer object to a object_reference.
461  *              Buffer.
462  *
463 
******************************************************************************/
464 
465 acpi_status
466 acpi_ns_convert_to_reference(struct acpi_namespace_node *scope,
467                  union acpi_operand_object *original_object,
468                  union acpi_operand_object **return_object)
469 {
470     union acpi_operand_object *new_object = NULL;
471     acpi_status status;
472     struct acpi_namespace_node *node;
473     union acpi_generic_state scope_info;
474     char *name;
475 
476     ACPI_FUNCTION_NAME(ns_convert_to_reference);
477 
478     /* Convert path into internal presentation */
479 
480     status =
481         acpi_ns_internalize_name(original_object->string.pointer, &name);
482     if (ACPI_FAILURE(status)) {
            // NO Bug. The return value is consistent with execution status
483         return_ACPI_STATUS(status);
484     }
485 
486     /* Find the namespace node */
487 
488     scope_info.scope.node =
489         ACPI_CAST_PTR(struct acpi_namespace_node, scope);
490     status =
491         acpi_ns_lookup(&scope_info, name, ACPI_TYPE_ANY,
ACPI_IMODE_EXECUTE,
492                ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
493                NULL, &node);
494     if (ACPI_FAILURE(status)) {
495 
496         /* Check if we are resolving a named reference within a package */
497 
            // Bug (1). The return value is inconsistent with execution status
498         ACPI_ERROR_NAMESPACE(original_object->string.pointer, status);
499         goto error_exit;
500     }
501 
502     /* Create and init a new internal ACPI object */
503 
504     new_object = acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_REFERENCE);
505     if (!new_object) {
506         status = AE_NO_MEMORY;
            // Bug (2). The return value is inconsistent with execution status
507         goto error_exit;
508     }
        ...
518 
519 error_exit:
520     ACPI_FREE(name);
521     *return_object = new_object;
522     return (AE_OK); // use "return_ACPI_STATUS(status);" ?
523 }

Thanks very much!

-- 
You are receiving this mail because:
You are watching the assignee of the bug.

------------------------------------------------------------------------------
_______________________________________________
acpi-bugzilla mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/acpi-bugzilla

Reply via email to