qemu-trivial
[Top][All Lists]
Advanced

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

Re: [Qemu-trivial] [PATCH v6 03/10] virtio-blk: fix reference a pointer


From: Michael Tokarev
Subject: Re: [Qemu-trivial] [PATCH v6 03/10] virtio-blk: fix reference a pointer which might be freed
Date: Thu, 14 Aug 2014 14:39:22 +0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.7.0

14.08.2014 14:37, Michael S. Tsirkin wrote:
> On Thu, Aug 14, 2014 at 03:29:14PM +0800, zhanghailiang wrote:
>> In function virtio_blk_handle_request, it may freed memory pointed by req,
>> So do not access member of req after calling this function.
>>
>> Reviewed-by: Stefan Hajnoczi <address@hidden>
>> Signed-off-by: zhanghailiang <address@hidden>
> 
> Reviewed-by: Michael S. Tsirkin <address@hidden>

Just a small nitpick...

> Stefan want to pick up this one?
> 
>> ---
>>  hw/block/virtio-blk.c | 5 +++--
>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
>> index c241c50..54a853a 100644
>> --- a/hw/block/virtio-blk.c
>> +++ b/hw/block/virtio-blk.c
>> @@ -458,7 +458,7 @@ static void virtio_blk_handle_output(VirtIODevice *vdev, 
>> VirtQueue *vq)
>>  static void virtio_blk_dma_restart_bh(void *opaque)
>>  {
>>      VirtIOBlock *s = opaque;
>> -    VirtIOBlockReq *req = s->rq;
>> +    VirtIOBlockReq *req = s->rq, *next = NULL;

There's no need to initialize next here.
With init like this I for one instinctively start searching below
how this `NULL' is used (which it isn't).

I'd declare it inside the loop too, since it is a local-to-loop
var, but that doesn't matter much.

/mjt

>>      MultiReqBuffer mrb = {
>>          .num_writes = 0,
>>      };
>> @@ -469,8 +469,9 @@ static void virtio_blk_dma_restart_bh(void *opaque)
>>      s->rq = NULL;
>>  
>>      while (req) {
>> +        next = req->next;
>>          virtio_blk_handle_request(req, &mrb);
>> -        req = req->next;
>> +        req = next;
>>      }
>>  
>>      virtio_submit_multiwrite(s->bs, &mrb);
>> -- 
>> 1.7.12.4
>>




reply via email to

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