virtio_ring: mark ring unused on error
Michael S. Tsirkin
maintainerPATCH 1/1 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.
--- drivers/virtio/virtio_ring.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/virtio/virtio_ring.c +3 -1
@@ -1197,8 +1197,10 @@ static inline int virtqueue_add_packed(struct virtqueue *_vq,if (virtqueue_use_indirect (_vq, total_sg)) { err =virtqueue_add_indirect_packed (vq, sgs, total_sg, out_sgs, in_sgs, data, gfp); -if (err != -ENOMEM ) +if (err != -ENOMEM ) { +END_USE (vq);return err; + }/* fall back on direct */ }
Signature · 1 line
MST
Quoted 9 lines · Michael S. Tsirkin
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_USEandEND_USEin the same function.Fixes fc6d70f40b3d ("virtio_ring: check desc == NULL when using indirect with packed")Cc "Xuan Zhuo" <[email protected]>Cc Jiasheng Jiang <[email protected]>Signed-off-by Michael S. Tsirkin <[email protected]>
LGTM
Quoted 21 lines
--- drivers/virtio/virtio_ring.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/virtio/virtio_ring.c +3
-2@@ -1197,8 +1197,10 @@ static inline int virtqueue_add_packed(struct virtqueue *_vq,if (virtqueue_use_indirect (_vq, total_sg)) { err =virtqueue_add_indirect_packed (vq, sgs, total_sg, out_sgs, in_sgs, data, gfp); -if (err != -ENOMEM ) +if (err != -ENOMEM ) { +END_USE (vq);return err; + }/* fall back on direct */ } --
Quoted 2 lines
MST
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Quoted 10 lines · Michael S. Tsirkin
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_USEandEND_USEin the same function.Fixes fc6d70f40b3d ("virtio_ring: check desc == NULL when using indirect with packed")Cc "Xuan Zhuo" <[email protected]>Cc Jiasheng Jiang <[email protected]>Signed-off-by Michael S. Tsirkin <[email protected]>
Quoted 23 lines
--- drivers/virtio/virtio_ring.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/virtio/virtio_ring.c +3
-2@@ -1197,8 +1197,10 @@ static inline int virtqueue_add_packed(struct virtqueue *_vq,if (virtqueue_use_indirect (_vq, total_sg)) { err =virtqueue_add_indirect_packed (vq, sgs, total_sg, out_sgs, in_sgs, data, gfp); -if (err != -ENOMEM ) +if (err != -ENOMEM ) { +END_USE (vq);return err; + }/* fall back on direct */ } --MST