summaryrefslogtreecommitdiff
path: root/drivers/pci
diff options
context:
space:
mode:
authorJiang Liu <jiang.liu@linux.intel.com>2013-12-19 12:38:12 (GMT)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-01-05 15:07:14 (GMT)
commit54e5bb46597e5eba63e460a1f96eb2021dc71fec (patch)
treefdd47cfce49f0a3fc4ed39623a28e133f4abc6f5 /drivers/pci
parenta65ac52041cccaf598995bc44340849027f1d79b (diff)
downloadlinux-54e5bb46597e5eba63e460a1f96eb2021dc71fec.tar.xz
PCI / pci-label: release allocated ACPI object on error recovery path
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>
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/pci-label.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/pci/pci-label.c b/drivers/pci/pci-label.c
index d51f45a..f6e01a5 100644
--- a/drivers/pci/pci-label.c
+++ b/drivers/pci/pci-label.c
@@ -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;
}