Skip to content

Commit 1861ba6

Browse files
committed
virtio_ring: mark ring unused on error
A recently added error path does not mark ring unused when exiting on OOM, which will lead to BUG on the next entry in debug builds. TODO: refactor code so we have START_USE and END_USE in the same function. Fixes: fc6d70f ("virtio_ring: check desc == NULL when using indirect with packed") Cc: "Xuan Zhuo" <[email protected]> Cc: Jiasheng Jiang <[email protected]> Reviewed-by: Xuan Zhuo <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 0800639 commit 1861ba6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/virtio/virtio_ring.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1197,8 +1197,10 @@ static inline int virtqueue_add_packed(struct virtqueue *_vq,
11971197
if (virtqueue_use_indirect(_vq, total_sg)) {
11981198
err = virtqueue_add_indirect_packed(vq, sgs, total_sg, out_sgs,
11991199
in_sgs, data, gfp);
1200-
if (err != -ENOMEM)
1200+
if (err != -ENOMEM) {
1201+
END_USE(vq);
12011202
return err;
1203+
}
12021204

12031205
/* fall back on direct */
12041206
}

0 commit comments

Comments
 (0)