PCI / pci-label: release allocated ACPI object on error recovery path
authorJiang Liu <jiang.liu@linux.intel.com>
Thu, 19 Dec 2013 12:38:12 +0000 (20:38 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Sun, 5 Jan 2014 15:07:14 +0000 (16:07 +0100)
Function dsm_get_label() leaks the returned ACPI object if
obj->package.count is not 2, so fix the possible memory leak.

Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/pci/pci-label.c

index d51f45aa669e5ff9184daab1df72776e8165aa84..f6e01a500d79a3f1a0a5b3858b6bff490642d180 100644 (file)
@@ -233,11 +233,7 @@ dsm_get_label(acpi_handle handle, int func,
                return -1;
 
        obj = (union acpi_object *)output->pointer;
-
-       switch (obj->type) {
-       case ACPI_TYPE_PACKAGE:
-               if (obj->package.count != 2)
-                       break;
+       if (obj->type == ACPI_TYPE_PACKAGE && obj->package.count == 2) {
                len = obj->package.elements[0].integer.value;
                if (buf) {
                        if (attribute == ACPI_ATTR_INDEX_SHOW)
@@ -250,10 +246,10 @@ dsm_get_label(acpi_handle handle, int func,
                }
                kfree(output->pointer);
                return len;
-       break;
-       default:
-               kfree(output->pointer);
        }
+
+       kfree(output->pointer);
+
        return -1;
 }