summaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci-label.c
diff options
context:
space:
mode:
authorJiang Liu <jiang.liu@linux.intel.com>2013-12-19 20:38:12 +0800
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-01-05 16:07:14 +0100
commit54e5bb46597e5eba63e460a1f96eb2021dc71fec (patch)
treefdd47cfce49f0a3fc4ed39623a28e133f4abc6f5 /drivers/pci/pci-label.c
parenta65ac52041cccaf598995bc44340849027f1d79b (diff)
downloadlinux-54e5bb46597e5eba63e460a1f96eb2021dc71fec.tar.bz2
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/pci-label.c')
-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 d51f45aa669e..f6e01a500d79 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;
}