Skip to contentSkip to conversation

virtio-blk: Fix use after release in virtio_blk_handle_rw_error

PATCH In review Jan Kiszka 4 participants 5 messages Apr 7, 2010

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 virtio-blk: Fix use after release in virtio_blk_handle_rw_error

virtio_blk_req_complete releases the request we dereference again for bdrv_mon_event. Reorder both calls to fix this.

---
 hw/virtio-blk.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hw/virtio-blk.c +1 -1
index 9915840..d5e8c79 100644
@@ -76,8 +76,8 @@ static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error,
         bdrv_mon_event(req->dev->bs, BDRV_ACTION_STOP, is_read);
         vm_stop(0);
     } else {
-        virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR);
         bdrv_mon_event(req->dev->bs, BDRV_ACTION_REPORT, is_read);
+        virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR);
     }
 
     return 1;
#1 lore raw
Quoted 2 lines · Jan Kiszka

virtio_blk_req_complete releases the request we dereference again for bdrv_mon_event. Reorder both calls to fix this.

I think Kevin alreday sent a patch to use the local state variable which is still around. Either way looks fine to me.

#2 lore raw

Am 07.04.2010 13:57, schrieb Christoph Hellwig:

Quoted 6 lines · Jan Kiszka
Quoted 2 lines

virtio_blk_req_complete releases the request we dereference again for bdrv_mon_event. Reorder both calls to fix this.

I think Kevin alreday sent a patch to use the local state variable which is still around. Either way looks fine to me.

Yes, it's the same thing, so I won't pick this up for my block branch even though Jan's fix looks fine, too.

Kevin

#3 lore raw
Quoted 10 lines · On Wed, 07 Apr 2010 14:18:26 +0200 Kevin Wolf <[email protected]> wrote:

Am 07.04.2010 13:57, schrieb Christoph Hellwig:

Quoted 6 lines · Jan Kiszka
Quoted 2 lines

virtio_blk_req_complete releases the request we dereference again for bdrv_mon_event. Reorder both calls to fix this.

I think Kevin alreday sent a patch to use the local state variable which is still around. Either way looks fine to me.

Yes, it's the same thing, so I won't pick this up for my block branch even though Jan's fix looks fine, too.

I also resend Kevin's fix two days ago as part of a git pull, but
looks like Anthony is away..

#4 lore raw
Quoted 8 lines · On Wed, 7 Apr 2010 09:32:35 -0300 Luiz Capitulino <[email protected]>…
Quoted 5 lines · On Wed, 07 Apr 2010 14:18:26 +0200 Kevin Wolf <[email protected]> wrote:

Am 07.04.2010 13:57, schrieb Christoph Hellwig:

Quoted 4 lines · Jan Kiszka
Quoted 2 lines

virtio_blk_req_complete releases the request we dereference again for bdrv_mon_event. Reorder both calls to fix this.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I think Kevin alreday sent a patch to use the local state variable which is still around. Either way looks fine to me.

Yes, it's the same thing, so I won't pick this up for my block branch even though Jan's fix looks fine, too.

I also resend Kevin's fix two days ago as part of a git pull, but
looks like Anthony is away..

A pull request, I mean.