mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-28 06:23:42 -04:00
virtio_balloon: warn on failed buffer add in stats_handle_request()
Like tell_host(), stats_handle_request() ignores the return value of virtqueue_add_outbuf() and kicks the queue regardless. The same "we should always be able to add one buffer to an empty queue" assumption does not hold once the virtqueue has been broken (e.g. on device shutdown), where the add fails with -EIO. Unlike tell_host() it does not wait_event() afterwards so it cannot hang, but it still kicks a queue with nothing queued. Warn and bail out on failure, mirroring tell_host() and virtballoon_free_page_report(). Suggested-by: David Hildenbrand <david@kernel.org> Signed-off-by: Denis V. Lunev <den@openvz.org> Reviewed-by: David Hildenbrand (Arm) <david@kernel.org> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-ID: <20260624154001.2733242-1-den@openvz.org>
This commit is contained in:
committed by
Michael S. Tsirkin
parent
198eda3950
commit
d62fb5cc8a
@@ -446,6 +446,7 @@ static void stats_handle_request(struct virtio_balloon *vb)
|
||||
struct virtqueue *vq;
|
||||
struct scatterlist sg;
|
||||
unsigned int len, num_stats;
|
||||
int err;
|
||||
|
||||
num_stats = update_balloon_stats(vb);
|
||||
|
||||
@@ -453,7 +454,9 @@ static void stats_handle_request(struct virtio_balloon *vb)
|
||||
if (!virtqueue_get_buf(vq, &len))
|
||||
return;
|
||||
sg_init_one(&sg, vb->stats, sizeof(vb->stats[0]) * num_stats);
|
||||
virtqueue_add_outbuf(vq, &sg, 1, vb, GFP_KERNEL);
|
||||
err = virtqueue_add_outbuf(vq, &sg, 1, vb, GFP_KERNEL);
|
||||
if (WARN_ON_ONCE(err))
|
||||
return;
|
||||
virtqueue_kick(vq);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user