On Fri, 27 Feb 2026 22:32:06 +0000
<[email protected]> wrote:

> From: Shiju Jose <[email protected]>

As for patch 1, nice if the title suggests what is being fixed.
With that,
Reviewed-by: Jonathan Cameron <[email protected]>

> 
> Component id in CXL events is 16 bytes data, but event record generation copy
> 15 bytes only from the qmp "component-id" field using strncpy.
> Replace strncpy with memcpy and change length of data to copy to the size of 
> the
> component_id array (16 bytes).
> 
> Signed-off-by: Shiju Jose <[email protected]>
> ---
>  hw/mem/cxl_type3.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c
> index 3cb1096e16..03a5d1751f 100644
> --- a/hw/mem/cxl_type3.c
> +++ b/hw/mem/cxl_type3.c
> @@ -1895,8 +1895,7 @@ void qmp_cxl_inject_general_media_event(const char 
> *path, CxlEventLog log,
>      }
>  
>      if (component_id) {
> -        strncpy((char *)gem.component_id, component_id,
> -                sizeof(gem.component_id) - 1);
> +        memcpy(gem.component_id, component_id, sizeof(gem.component_id));
>          valid_flags |= CXL_GMER_VALID_COMPONENT;
>          if (has_comp_id_pldm && is_comp_id_pldm) {
>              valid_flags |= CXL_GMER_VALID_COMPONENT_ID_FORMAT;
> @@ -2066,8 +2065,7 @@ void qmp_cxl_inject_dram_event(const char *path, 
> CxlEventLog log,
>      }
>  
>      if (component_id) {
> -        strncpy((char *)dram.component_id, component_id,
> -                sizeof(dram.component_id) - 1);
> +        memcpy(dram.component_id, component_id, sizeof(dram.component_id));
>          valid_flags |= CXL_DRAM_VALID_COMPONENT;
>          if (has_comp_id_pldm && is_comp_id_pldm) {
>              valid_flags |= CXL_DRAM_VALID_COMPONENT_ID_FORMAT;
> @@ -2185,8 +2183,7 @@ void qmp_cxl_inject_memory_module_event(const char 
> *path, CxlEventLog log,
>               corrected_persist_error_count);
>  
>      if (component_id) {
> -        strncpy((char *)module.component_id, component_id,
> -                sizeof(module.component_id) - 1);
> +        memcpy(module.component_id, component_id, 
> sizeof(module.component_id));
>          valid_flags |= CXL_MMER_VALID_COMPONENT;
>          if (has_comp_id_pldm && is_comp_id_pldm) {
>              valid_flags |= CXL_MMER_VALID_COMPONENT_ID_FORMAT;


Reply via email to