[edk2-devel] [edk2-redfish-client][PATCH 1/4] RedfishClientPkg: add check for NULL pointer to avoid ASSERT

Mike Maslenkin posted 4 patches 2 years, 1 month ago
There is a newer version of this series
[edk2-devel] [edk2-redfish-client][PATCH 1/4] RedfishClientPkg: add check for NULL pointer to avoid ASSERT
Posted by Mike Maslenkin 2 years, 1 month ago
Initially RedfishPlatformConfigGetConfigureLang could return success
even if ConfigureLangList is empty. After fixing this condition,
RedfishPlatformConfigGetConfigureLang returns an error, but this doesn't
help to avoid ASSERT because the error path is the same as for non-empty
list.

Cc: Abner Chang <abner.chang@amd.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Cc: Nickle Wang <nicklew@nvidia.com>
Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com>
---
 .../RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c       | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
index 4cb7621c25c4..0f0b050d7eba 100644
--- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
+++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
@@ -3118,7 +3118,9 @@ LeaveFunction:
     FreePool (ConfigureLangBuffer);
   }
 
-  FreePool (ConfigureLangList);
+  if (ConfigureLangList != NULL) {
+    FreePool (ConfigureLangList);
+  }
 
   *NumberOfValues = (UINT32)ListCount;
   return FirstEmptyPropKeyValueList;
-- 
2.32.0 (Apple Git-132)



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112574): https://edk2.groups.io/g/devel/message/112574
Mute This Topic: https://groups.io/mt/103181638/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [edk2-redfish-client][PATCH 1/4] RedfishClientPkg: add check for NULL pointer to avoid ASSERT
Posted by Nickle Wang via groups.io 2 years, 1 month ago

Reviewed-by: Nickle Wang <nicklew@nvidia.com>

Regards,
Nickle

> -----Original Message-----
> From: Mike Maslenkin <mike.maslenkin@gmail.com>
> Sent: Friday, December 15, 2023 8:04 AM
> To: devel@edk2.groups.io
> Cc: abner.chang@amd.com; Nickle Wang <nicklew@nvidia.com>;
> igork@ami.com; Mike Maslenkin <mike.maslenkin@gmail.com>
> Subject: [edk2-redfish-client][PATCH 1/4] RedfishClientPkg: add check for NULL
> pointer to avoid ASSERT
> 
> External email: Use caution opening links or attachments
> 
> 
> Initially RedfishPlatformConfigGetConfigureLang could return success even if
> ConfigureLangList is empty. After fixing this condition,
> RedfishPlatformConfigGetConfigureLang returns an error, but this doesn't help to
> avoid ASSERT because the error path is the same as for non-empty list.
> 
> Cc: Abner Chang <abner.chang@amd.com>
> Cc: Igor Kulchytskyy <igork@ami.com>
> Cc: Nickle Wang <nicklew@nvidia.com>
> Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com>
> ---
>  .../RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c       | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git
> a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
> b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
> index 4cb7621c25c4..0f0b050d7eba 100644
> ---
> a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
> +++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUt
> +++ ilityLib.c
> @@ -3118,7 +3118,9 @@ LeaveFunction:
>      FreePool (ConfigureLangBuffer);
> 
>    }
> 
> 
> 
> -  FreePool (ConfigureLangList);
> 
> +  if (ConfigureLangList != NULL) {
> 
> +    FreePool (ConfigureLangList);
> 
> +  }
> 
> 
> 
>    *NumberOfValues = (UINT32)ListCount;
> 
>    return FirstEmptyPropKeyValueList;
> 
> --
> 2.32.0 (Apple Git-132)



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112580): https://edk2.groups.io/g/devel/message/112580
Mute This Topic: https://groups.io/mt/103181638/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-