qemu-block
[Top][All Lists]
Advanced

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

Re: [PATCH v3 03/33] block/nbd: ensure ->connection_thread is always val


From: Eric Blake
Subject: Re: [PATCH v3 03/33] block/nbd: ensure ->connection_thread is always valid
Date: Tue, 1 Jun 2021 16:41:46 -0500
User-agent: NeoMutt/20210205

On Fri, Apr 16, 2021 at 11:08:41AM +0300, Vladimir Sementsov-Ogievskiy wrote:
> From: Roman Kagan <rvkagan@yandex-team.ru>
> 
> Simplify lifetime management of BDRVNBDState->connect_thread by
> delaying the possible cleanup of it until the BDRVNBDState itself goes
> away.
> 
> This also reverts
>  0267101af6 "block/nbd: fix possible use after free of s->connect_thread"
> as now s->connect_thread can't be cleared until the very end.
> 
> Signed-off-by: Roman Kagan <rvkagan@yandex-team.ru>
>  [vsementsov: rebase, revert 0267101af6 changes]
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  block/nbd.c | 56 ++++++++++++++++++++---------------------------------
>  1 file changed, 21 insertions(+), 35 deletions(-)
> 

>  static void nbd_clear_bdrvstate(BlockDriverState *bs)
>  {
>      BDRVNBDState *s = (BDRVNBDState *)bs->opaque;
> +    NBDConnectThread *thr = s->connect_thread;
> +    bool thr_running;
> +
> +    qemu_mutex_lock(&thr->mutex);
> +    thr_running = thr->state == CONNECT_THREAD_RUNNING;
> +    if (thr_running) {
> +        thr->state = CONNECT_THREAD_RUNNING_DETACHED;
> +    }
> +    qemu_mutex_unlock(&thr->mutex);
> +
> +    /* the runaway thread will clean it up itself */

s/clean it up/clean up/

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org




reply via email to

[Prev in Thread] Current Thread [Next in Thread]