On Fri, 16 Feb 2024 at 11:08, Philippe Mathieu-Daudé <phi...@linaro.org> wrote:
>
> When the QOM parent is available, prefer object_initialize_child()
> over object_initialize(), since it create the parent relationship.
>
> Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org>
> ---
>  hw/net/can/xlnx-versal-canfd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/net/can/xlnx-versal-canfd.c b/hw/net/can/xlnx-versal-canfd.c
> index 47a14cfe63..f8e4bd75e4 100644
> --- a/hw/net/can/xlnx-versal-canfd.c
> +++ b/hw/net/can/xlnx-versal-canfd.c
> @@ -1900,7 +1900,7 @@ static int canfd_populate_regarray(XlnxVersalCANFDState 
> *s,
>          int index = rae[i].addr / 4;
>          RegisterInfo *r = &s->reg_info[index];
>
> -        object_initialize(r, sizeof(*r), TYPE_REGISTER);
> +        object_initialize_child(OBJECT(s), "reg[*]", r, TYPE_REGISTER);
>
>          *r = (RegisterInfo) {
>              .data = &s->regs[index],
> --

Hi -- I was just looking at this function since ASAN
reports a leak in it. I notice that this patch never got
applied -- any reason why?

Also, though, we call object_initialize(r, ...) and then
we immediately do "*r = { some struct }" which entirely
overwrites the initialization we just did. I guess that
should instead be initializing the individual fields...

-- PMM

Reply via email to