qemu-block
[Top][All Lists]
Advanced

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

Re: [Qemu-block] [PATCH 02/18] blockjob: introduce .drain callback for j


From: Paolo Bonzini
Subject: Re: [Qemu-block] [PATCH 02/18] blockjob: introduce .drain callback for jobs
Date: Mon, 17 Oct 2016 09:53:49 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0


On 16/10/2016 12:02, Stefan Hajnoczi wrote:
> On Thu, Oct 13, 2016 at 07:34:06PM +0200, Paolo Bonzini wrote:
>> +static void backup_drain(BlockJob *job)
>> +{
>> +    BackupBlockJob *s = container_of(job, BackupBlockJob, common);
>> +
>> +    /* Need to keep a reference in case blk_drain triggers execution
>> +     * of backup_complete...
>> +     */
>> +    if (s->target) {
>> +        blk_ref(s->target);
>> +        blk_drain(s->target);
>> +        blk_unref(s->target);
>> +    }
> [...]
>> @@ -331,6 +346,7 @@ static void backup_complete(BlockJob *job, void *opaque)
>>      BackupCompleteData *data = opaque;
>>  
>>      blk_unref(s->target);
>> +    s->target = NULL;
> 
> Will blk_unref(s->target) segfault since backup_complete() has set it to
> NULL?  I expected backup_drain() to stash the pointer in a local
> variable to avoid using s->target.

Yes, indeed.

Paolo



reply via email to

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