From: Jiang Liu <jiang.liu@linux.intel.com>
To: "Rafael J . Wysocki" <rafael.j.wysocki@intel.com>,
Bjorn Helgaas <bhelgaas@google.com>,
Lv Zheng <lv.zheng@intel.com>, Len Brown <lenb@kernel.org>,
Leonidas Da Silva Barbosa <leosilva@linux.vnet.ibm.com>,
Ashley Lai <ashley@ashleylai.com>,
Peter Huewe <peterhuewe@gmx.de>, Rajiv Andrade <mail@srajiv.net>,
Marcel Selhorst <tpmdd@selhorst.net>,
Sirrix AG <tpmdd@sirrix.com>,
Daniel Vetter <daniel.vetter@ffwll.ch>,
David Airlie <airlied@linux.ie>, Jiri Kosina <jkosina@suse.cz>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Jiang Liu <jiang.liu@linux.intel.com>, Tony Luck <tony.luck@intel.com>
Subject: [RFC Patch v1 03/13] PCI, pci-label: release allocated ACPI object on error recovery path
Date: Wed, 18 Dec 2013 14:58:11 +0800 [thread overview]
Message-ID: <1387349901-3391-4-git-send-email-jiang.liu@linux.intel.com> (raw)
In-Reply-To: <1387349901-3391-1-git-send-email-jiang.liu@linux.intel.com>
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>
---
drivers/pci/pci-label.c | 12 ++++--------
1 file 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;
}
--
1.7.10.4
next parent reply other threads:[~2013-12-18 6:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1387349901-3391-1-git-send-email-jiang.liu@linux.intel.com>
2013-12-18 6:58 ` Jiang Liu [this message]
2013-12-18 6:58 ` [RFC Patch v1 04/13] ACPI, PCI: replace open-coded _DSM specific code with helper functions Jiang Liu
2013-12-18 6:58 ` [RFC Patch v1 05/13] PCI, pci-label: treat PCI label with index 0 as valid label Jiang Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1387349901-3391-4-git-send-email-jiang.liu@linux.intel.com \
--to=jiang.liu@linux.intel.com \
--cc=airlied@linux.ie \
--cc=ashley@ashleylai.com \
--cc=bhelgaas@google.com \
--cc=daniel.vetter@ffwll.ch \
--cc=jkosina@suse.cz \
--cc=lenb@kernel.org \
--cc=leosilva@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lv.zheng@intel.com \
--cc=mail@srajiv.net \
--cc=peterhuewe@gmx.de \
--cc=rafael.j.wysocki@intel.com \
--cc=tony.luck@intel.com \
--cc=tpmdd@selhorst.net \
--cc=tpmdd@sirrix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).