Skip to contentSkip to conversation

usb: core: Make use of acpi_evaluate_object() status

PATCH New Andy Shevchenko 1 participant 1 message Feb 18, 2020 USB

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 usb: core: Make use of acpi_evaluate_object() status

Compiler is not happy about dangling variable:

.../core/usb-acpi.c: In function ‘usb_acpi_get_connect_type’:
.../core/usb-acpi.c:90:14: warning: variable ‘status’ set but not used [-Wunused-but-set-variable]

   90 |  acpi_status status;
      |              ^~~~~~

Make use of it by checking the status and bail out in case of error.

---
v2: Drop unneded {} (Sergei)

 drivers/usb/core/usb-acpi.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/usb/core/usb-acpi.c +5 -4
index 9043d7242d67..99d41dc26e08 100644
@@ -86,7 +86,7 @@ static enum usb_port_connect_type usb_acpi_get_connect_type(acpi_handle handle,
 {
 	enum usb_port_connect_type connect_type = USB_PORT_CONNECT_TYPE_UNKNOWN;
 	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
-	union acpi_object *upc;
+	union acpi_object *upc = NULL;
 	acpi_status status;
 
 	/*
@@ -98,11 +98,12 @@ static enum usb_port_connect_type usb_acpi_get_connect_type(acpi_handle handle,
 	 * no connectable, the port would be not used.
 	 */
 	status = acpi_evaluate_object(handle, "_UPC", NULL, &buffer);
+	if (ACPI_FAILURE(status))
+		goto out;
+
 	upc = buffer.pointer;
-	if (!upc || (upc->type != ACPI_TYPE_PACKAGE)
-		|| upc->package.count != 4) {
+	if (!upc || (upc->type != ACPI_TYPE_PACKAGE) || upc->package.count != 4)
 		goto out;
-	}
 
 	if (upc->package.elements[0].integer.value)
 		if (pld->user_visible)
Signature · 1 line
2.25.0