* [PATCH EDK2 v1 0/1] RedfishPkg: fix memory leak issue @ 2022-03-10 11:25 wenyi,xie 2022-03-10 11:25 ` [PATCH EDK2 v1 1/1] " wenyi,xie 0 siblings, 1 reply; 5+ messages in thread From: wenyi,xie @ 2022-03-10 11:25 UTC (permalink / raw) To: devel, abner.chang, nickle.wang; +Cc: songdongkuang, xiewenyi2 Main Changes : 1.free the allocated memory when function collectionEvalOp return. 2.optimeze the code, no functional change. Wenyi Xie (1): RedfishPkg: fix memory leak issue RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/payload.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) -- 2.20.1.windows.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH EDK2 v1 1/1] RedfishPkg: fix memory leak issue 2022-03-10 11:25 [PATCH EDK2 v1 0/1] RedfishPkg: fix memory leak issue wenyi,xie @ 2022-03-10 11:25 ` wenyi,xie 2022-03-11 5:48 ` Abner Chang 0 siblings, 1 reply; 5+ messages in thread From: wenyi,xie @ 2022-03-10 11:25 UTC (permalink / raw) To: devel, abner.chang, nickle.wang; +Cc: songdongkuang, xiewenyi2 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 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH EDK2 v1 1/1] RedfishPkg: fix memory leak issue 2022-03-10 11:25 ` [PATCH EDK2 v1 1/1] " wenyi,xie @ 2022-03-11 5:48 ` Abner Chang 2022-03-11 7:03 ` Abner Chang 0 siblings, 1 reply; 5+ messages in thread From: Abner Chang @ 2022-03-11 5:48 UTC (permalink / raw) To: Wenyi Xie, devel@edk2.groups.io, Wang, Nickle (Server BIOS) Cc: songdongkuang@huawei.com Thanks for catching this. Reviewed-by: Abner Chang <abner.chang@hpe.com> > -----Original Message----- > From: Wenyi Xie <xiewenyi2@huawei.com> > Sent: Thursday, March 10, 2022 7:26 PM > To: devel@edk2.groups.io; Chang, Abner (HPS SW/FW Technologist) > <abner.chang@hpe.com>; Wang, Nickle (Server BIOS) > <nickle.wang@hpe.com> > Cc: songdongkuang@huawei.com; xiewenyi2@huawei.com > Subject: [PATCH EDK2 v1 1/1] RedfishPkg: fix memory leak issue > > 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH EDK2 v1 1/1] RedfishPkg: fix memory leak issue 2022-03-11 5:48 ` Abner Chang @ 2022-03-11 7:03 ` Abner Chang 2022-03-11 8:02 ` wenyi,xie 0 siblings, 1 reply; 5+ messages in thread From: Abner Chang @ 2022-03-11 7:03 UTC (permalink / raw) To: Wenyi Xie, devel@edk2.groups.io, Wang, Nickle (Server BIOS) Cc: songdongkuang@huawei.com [-- Attachment #1: Type: text/plain, Size: 2861 bytes --] Hi Wenyi, Please add my RB in the commit message and create the PR against edk2, let me know the link to PR as well. Thanks, Abner ________________________________ From: Chang, Abner (HPS SW/FW Technologist) Sent: Friday, March 11, 2022 1:48 PM To: Wenyi Xie <xiewenyi2@huawei.com>; devel@edk2.groups.io <devel@edk2.groups.io>; Wang, Nickle (Server BIOS) <nickle.wang@hpe.com> Cc: songdongkuang@huawei.com <songdongkuang@huawei.com> Subject: RE: [PATCH EDK2 v1 1/1] RedfishPkg: fix memory leak issue Thanks for catching this. Reviewed-by: Abner Chang <abner.chang@hpe.com> > -----Original Message----- > From: Wenyi Xie <xiewenyi2@huawei.com> > Sent: Thursday, March 10, 2022 7:26 PM > To: devel@edk2.groups.io; Chang, Abner (HPS SW/FW Technologist) > <abner.chang@hpe.com>; Wang, Nickle (Server BIOS) > <nickle.wang@hpe.com> > Cc: songdongkuang@huawei.com; xiewenyi2@huawei.com > Subject: [PATCH EDK2 v1 1/1] RedfishPkg: fix memory leak issue > > 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 [-- Attachment #2: Type: text/html, Size: 5504 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH EDK2 v1 1/1] RedfishPkg: fix memory leak issue 2022-03-11 7:03 ` Abner Chang @ 2022-03-11 8:02 ` wenyi,xie 0 siblings, 0 replies; 5+ messages in thread From: wenyi,xie @ 2022-03-11 8:02 UTC (permalink / raw) To: Chang, Abner (HPS SW/FW Technologist), devel@edk2.groups.io, Wang, Nickle (Server BIOS) Cc: songdongkuang@huawei.com Hi Abner, Thank you for your reviewing, here is the link to the PR. https://github.com/tianocore/edk2/pull/2612 Regards Wenyi On 2022/3/11 15:03, Chang, Abner (HPS SW/FW Technologist) wrote: > Hi Wenyi, > Please add my RB in the commit message and create the PR against edk2, let me know the link to PR as well. > > Thanks, > Abner > ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ > *From:* Chang, Abner (HPS SW/FW Technologist) > *Sent:* Friday, March 11, 2022 1:48 PM > *To:* Wenyi Xie <xiewenyi2@huawei.com>; devel@edk2.groups.io <devel@edk2.groups.io>; Wang, Nickle (Server BIOS) <nickle.wang@hpe.com> > *Cc:* songdongkuang@huawei.com <songdongkuang@huawei.com> > *Subject:* RE: [PATCH EDK2 v1 1/1] RedfishPkg: fix memory leak issue > > Thanks for catching this. > > Reviewed-by: Abner Chang <abner.chang@hpe.com> > >> -----Original Message----- >> From: Wenyi Xie <xiewenyi2@huawei.com> >> Sent: Thursday, March 10, 2022 7:26 PM >> To: devel@edk2.groups.io; Chang, Abner (HPS SW/FW Technologist) >> <abner.chang@hpe.com>; Wang, Nickle (Server BIOS) >> <nickle.wang@hpe.com> >> Cc: songdongkuang@huawei.com; xiewenyi2@huawei.com >> Subject: [PATCH EDK2 v1 1/1] RedfishPkg: fix memory leak issue >> >> 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 > ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-03-11 8:03 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-03-10 11:25 [PATCH EDK2 v1 0/1] RedfishPkg: fix memory leak issue wenyi,xie 2022-03-10 11:25 ` [PATCH EDK2 v1 1/1] " wenyi,xie 2022-03-11 5:48 ` Abner Chang 2022-03-11 7:03 ` Abner Chang 2022-03-11 8:02 ` wenyi,xie
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox