qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: "Cong Liu" <liucong2@kylinos.cn>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Alexandre Iooss" <erdnaxe@crans.org>,
	"Mahmoud Mandour" <ma.mandourr@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH] plugins/hotblocks: Fix potential deadlock in plugin_exit() function
Date: Thu, 21 Sep 2023 09:43:52 +0200	[thread overview]
Message-ID: <8c11bc64-e22f-6ad9-af3e-e7a690536539@linaro.org> (raw)
In-Reply-To: <20230921061231.60948-1-liucong2@kylinos.cn>

Hi Cong,

On 21/9/23 08:12, Cong Liu wrote:
> This patch fixes a potential deadlock in the plugin_exit() function of QEMU.
> The original code does not release the lock mutex if it is NULL. This patch
> adds a check for it being NULL and releases the mutex in that case.

You are correct.

> Signed-off-by: Cong Liu <liucong2@kylinos.cn>
> ---
>   contrib/plugins/hotblocks.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/contrib/plugins/hotblocks.c b/contrib/plugins/hotblocks.c
> index 6b74d25fead6..1f713f1904f3 100644
> --- a/contrib/plugins/hotblocks.c
> +++ b/contrib/plugins/hotblocks.c
> @@ -70,6 +70,8 @@ static void plugin_exit(qemu_plugin_id_t id, void *p)
>   
>           g_list_free(it);
>           g_mutex_unlock(&lock);
> +    } else {
> +        g_mutex_unlock(&lock);
>       }

The code stays simpler if you simply move the unlock call out
of the if() statement, here.

>   
>       qemu_plugin_outs(report->str);

Regards,

Phil.


  reply	other threads:[~2023-09-21  7:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-21  6:12 [PATCH] plugins/hotblocks: Fix potential deadlock in plugin_exit() function Cong Liu
2023-09-21  7:43 ` Philippe Mathieu-Daudé [this message]
2023-09-21  9:23   ` [PATCH v2] " Cong Liu
2023-09-21 10:24     ` Philippe Mathieu-Daudé

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=8c11bc64-e22f-6ad9-af3e-e7a690536539@linaro.org \
    --to=philmd@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=erdnaxe@crans.org \
    --cc=liucong2@kylinos.cn \
    --cc=ma.mandourr@gmail.com \
    --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;
as well as URLs for NNTP newsgroup(s).