public inbox for qemu-devel@nongnu.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: Jiri Pirko <jiri@resnulli.us>, Jason Wang <jasowang@redhat.com>
Subject: Re: [PATCH] hw/net/rocker: Avoid double-free of l2_flood.group_ids
Date: Wed, 25 Mar 2026 11:00:18 +0100	[thread overview]
Message-ID: <2395a353-36a9-49ba-bb0c-824f308cc90d@linaro.org> (raw)
In-Reply-To: <20260324193530.375628-1-peter.maydell@linaro.org>

On 24/3/26 20:35, Peter Maydell wrote:
> In of_dpa_cmd_add_l2_flood(), we allocate memory for the
> group->l2_flood.group_ids array, freeing any previous array.
> However, in the error-exit path we free the group_ids memory but do
> not clear the pointer to NULL.  This means that if the guest causes
> us to take the error-exit path and then later call the function
> again, we will try again to free the memory we already freed.
> 
> Fix this by clearing the group_ids pointer in the error exit
> path, so we maintain the invariant of "either it points at
> allocated memory, or it is NULL" (both being valid to g_free()).
> 
> Cc: qemu-stable@nongnu.org
> Fixes: dc488f88806 ("rocker: add new rocker switch device")
> Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3253
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/net/rocker/rocker_of_dpa.c | 1 +
>   1 file changed, 1 insertion(+)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>


      reply	other threads:[~2026-03-25 10:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-24 19:35 [PATCH] hw/net/rocker: Avoid double-free of l2_flood.group_ids Peter Maydell
2026-03-25 10:00 ` Philippe Mathieu-Daudé [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2395a353-36a9-49ba-bb0c-824f308cc90d@linaro.org \
    --to=philmd@linaro.org \
    --cc=jasowang@redhat.com \
    --cc=jiri@resnulli.us \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox