From: "wenyi,xie" <xiewenyi2@huawei.com>
To: <devel@edk2.groups.io>, <abner.chang@hpe.com>, <nickle.wang@hpe.com>
Cc: <songdongkuang@huawei.com>, <xiewenyi2@huawei.com>
Subject: [PATCH EDK2 v1 1/1] RedfishPkg: fix memory leak issue
Date: Thu, 10 Mar 2022 19:25:34 +0800 [thread overview]
Message-ID: <20220310112534.2952545-2-xiewenyi2@huawei.com> (raw)
In-Reply-To: <20220310112534.2952545-1-xiewenyi2@huawei.com>
The calloc memory is not free when function collectionEvalOp
return in the halfway.
Cc: Abner Chang <abner.chang@hpe.com>
Cc: Nickle Wang <nickle.wang@hpe.com>
Signed-off-by: Wenyi Xie <xiewenyi2@huawei.com>
---
RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/payload.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/payload.c b/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/payload.c
index 3f2b83e834d0..6c6e2246abe3 100644
--- a/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/payload.c
+++ b/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/payload.c
@@ -620,6 +620,7 @@ collectionEvalOp (
if (((*StatusCode == NULL) && (members == NULL)) ||
((*StatusCode != NULL) && ((**StatusCode < HTTP_STATUS_200_OK) || (**StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))))
{
+ free (valid);
return members;
}
@@ -633,6 +634,7 @@ collectionEvalOp (
if (((*StatusCode == NULL) && (tmp == NULL)) ||
((*StatusCode != NULL) && ((**StatusCode < HTTP_STATUS_200_OK) || (**StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))))
{
+ free (valid);
return tmp;
}
@@ -658,19 +660,15 @@ collectionEvalOp (
cleanupPayload (members);
if (validCount == 0) {
- free (valid);
- return NULL;
- }
-
- if (validCount == 1) {
+ ret = NULL;
+ } else if (validCount == 1) {
ret = valid[0];
- free (valid);
- return ret;
} else {
ret = createCollection (payload->service, validCount, valid);
- free (valid);
- return ret;
}
+
+ free (valid);
+ return ret;
}
static redfishPayload *
--
2.20.1.windows.1
next prev parent reply other threads:[~2022-03-10 11:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-10 11:25 [PATCH EDK2 v1 0/1] RedfishPkg: fix memory leak issue wenyi,xie
2022-03-10 11:25 ` wenyi,xie [this message]
2022-03-11 5:48 ` [PATCH EDK2 v1 1/1] " Abner Chang
2022-03-11 7:03 ` Abner Chang
2022-03-11 8:02 ` wenyi,xie
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-list 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=20220310112534.2952545-2-xiewenyi2@huawei.com \
--to=devel@edk2.groups.io \
/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