virtio-blk: fix reference a pointer which might be freed
authorzhanghailiang <zhang.zhanghailiang@huawei.com>
Mon, 18 Aug 2014 07:42:50 +0000 (15:42 +0800)
committerKevin Wolf <kwolf@redhat.com>
Wed, 20 Aug 2014 09:57:05 +0000 (11:57 +0200)
In function virtio_blk_handle_request, it may freed memory pointed by req,
So do not access member of req after calling this function.

Cc: qemu-stable@nongnu.org
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
hw/block/virtio-blk.c

index 302c39e2be137514c37fe3a3b3df4d0fd387eb01..d9167ce9a362207f555284cd09067010a824a91e 100644 (file)
@@ -469,8 +469,9 @@ static void virtio_blk_dma_restart_bh(void *opaque)
     s->rq = NULL;
 
     while (req) {
+        VirtIOBlockReq *next = req->next;
         virtio_blk_handle_request(req, &mrb);
-        req = req->next;
+        req = next;
     }
 
     virtio_submit_multiwrite(s->bs, &mrb);