[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 7/7] Add ConfigFreeActive / ConfigFreeSzValue



On 11/11/2025 09:34, Owen Smith wrote:
> Values returned by ConfigGetActive should be freed by ConfigFreeActive,
> and values returned by ConfigQuerySystemStartOption should be freed by
> ConfigFreeSzValue, so that pool tag tracking is correct.
> 
> Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
> ---
>   include/xen.h       | 12 ++++++++++++
>   src/xen/config.c    | 22 ++++++++++++++++++++--
>   src/xenbus/fdo.c    |  6 +++---
>   src/xenbus/unplug.c |  2 +-
>   4 files changed, 36 insertions(+), 6 deletions(-)
> 
> diff --git a/include/xen.h b/include/xen.h
> index 7016c86..8691a0f 100644
> --- a/include/xen.h
> +++ b/include/xen.h
> @@ -573,6 +573,12 @@ ConfigClearActive(
>       VOID
>       );
>   
> +XEN_API
> +VOID
> +ConfigFreeActive(
> +    _In_ PSTR   Value
> +    );
> +
>   XEN_API
>   NTSTATUS
>   ConfigRequestReboot(
> @@ -587,4 +593,10 @@ ConfigQuerySystemStartOption(
>       _Outptr_ PANSI_STRING   *Option
>       );
>   
> +XEN_API
> +VOID
> +ConfigFreeSzValue(
> +    _In_ PANSI_STRING       Array
> +    );
> +
>   #endif  // _XEN_H
> diff --git a/src/xen/config.c b/src/xen/config.c
> index 99980a6..b7268c0 100644
> --- a/src/xen/config.c
> +++ b/src/xen/config.c
> @@ -305,7 +305,7 @@ ConfigUpdateActive(
>   
>       status = ConfigGetActive("InstanceID", &ActiveInstanceID);
>       if (NT_SUCCESS(status)) {
> -        ExFreePool(ActiveInstanceID);
> +        ConfigFreeActive(ActiveInstanceID);
>       } else {
>           RtlInitAnsiString(&Ansi[0], InstanceID);
>   
> @@ -319,7 +319,7 @@ ConfigUpdateActive(
>   
>       status = ConfigGetActive("LocationInformation", 
> &ActiveLocationInformation);
>       if (NT_SUCCESS(status)) {
> -        ExFreePool(ActiveLocationInformation);
> +        ConfigFreeActive(ActiveLocationInformation);
>       } else {
>           RtlInitAnsiString(&Ansi[0], LocationInformation);
>   
> @@ -408,6 +408,15 @@ fail1:
>       return status;
>   }
>   
> +XEN_API
> +VOID
> +ConfigFreeActive(
> +    _In_ PSTR   Value
> +    )
> +{
> +    __FreePoolWithTag(Value, 'SUB');

Perhaps this should be under a #define like the other pool tags?

> +}
> +
>   XEN_API
>   NTSTATUS
>   ConfigRequestReboot(
> @@ -496,3 +505,12 @@ ConfigQuerySystemStartOption(
>   {
>       return RegistryQuerySystemStartOption(Key, Option);
>   }
> +
> +XEN_API
> +VOID
> +ConfigFreeSzValue(
> +    _In_ PANSI_STRING       Array
> +    )
> +{
> +    RegistryFreeSzValue(Array);
> +}
> diff --git a/src/xenbus/fdo.c b/src/xenbus/fdo.c
> index e3de8b9..d093db8 100644
> --- a/src/xenbus/fdo.c
> +++ b/src/xenbus/fdo.c
> @@ -806,7 +806,7 @@ fallback:
>           if (Fdo->Active)
>               (VOID) ConfigUpdateActive(DeviceID, InstanceID, 
> LocationInformation);
>   
> -        ExFreePool(ActiveDeviceID);
> +        ConfigFreeActive(ActiveDeviceID);
>       } else {
>           status = ConfigSetActive(DeviceID, InstanceID, LocationInformation);
>           if (NT_SUCCESS(status))
> @@ -5746,7 +5746,7 @@ FdoBalloonInitialize(
>       else if (strcmp(Value, "ON") != 0)
>           Warning("UNRECOGNIZED VALUE OF %s: %s\n", Key, Value);
>   
> -    RegistryFreeSzValue(Option);
> +    ConfigFreeSzValue(Option);
>   
>   done:
>       return Enabled ?
> @@ -5782,7 +5782,7 @@ FdoSetWatchdog(
>   
>       Value = strtoul(Option->Buffer + sizeof (Key) - 1, NULL, 0);
>   
> -    RegistryFreeSzValue(Option);
> +    ConfigFreeSzValue(Option);
>   
>       if (Value && Value < 10) {
>           Warning("%us TOO SHORT (ROUNDING UP TO 10s)\n");
> diff --git a/src/xenbus/unplug.c b/src/xenbus/unplug.c
> index ca58c31..6bf8fb3 100644
> --- a/src/xenbus/unplug.c
> +++ b/src/xenbus/unplug.c
> @@ -175,7 +175,7 @@ UnplugBootEmulated(
>       else if (strcmp(Value, "FALSE") != 0)
>           Warning("UNRECOGNIZED VALUE OF %s: %s\n", KeyName, Value);
>   
> -    RegistryFreeSzValue(Option);
> +    ConfigFreeSzValue(Option);
>   
>   done:
>       ReleaseMutex(&Context->Mutex);



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.