From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E96E3C942C for ; Wed, 24 Jun 2026 15:40:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782315610; cv=none; b=TwO/49SqdrghJ2NZ9byM6Zzu0eRXfqS5c+HUI/hJ/aQaMLSNUfBbeqzISV3QF2YTdfw6YYKA8qrtTFN3HGtmhfsjh1BU0XVr8cRAjCiZShfqZAafXJGz3O7jKMybNaw9PoEOsT7yLetYm8mpNyKTHqxxm6SgNY8eW+idUj2aREc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782315610; c=relaxed/simple; bh=+ftY4ThfwoEF3KS8z4f4RgMIAbP5Tx1p3bFUFB6zzLI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fGgAbvl10bTgvs1+FWniJiii1rUDo4M5MFbXy1utx6K/CdbTQm/1QbTfQHNm6ZTZGb2tvtrUDGioCywiYTSoqf0OpshYQ3vuZTA34eRXqDUhXqjbWa1OxL2jchEQmg78m7q1U9i90bSjtuzloPpVoULTVeHBL4xloywhACOBLgo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=openvz.org; spf=pass smtp.mailfrom=openvz.org; dkim=pass (2048-bit key) header.d=openvz.org header.i=@openvz.org header.b=Ep41CiLq; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=openvz.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=openvz.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=openvz.org header.i=@openvz.org header.b="Ep41CiLq" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-490b211ee6aso7758415e9.3 for ; Wed, 24 Jun 2026 08:40:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1782315605; x=1782920405; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bkYQNO5vR+uN9JdITatzFgUTsrAKtjKJYqqqqrE2vc8=; b=Ep41CiLq7ubOPoilFDNrEVjKW02vHpha8D0LKvZabQSCkfaA7T2BVv3ISATXDCvnuD 7tQMuppWgXhxvY1NLDmdPza84haH2nbVikC179+PaD35v9/dltn2lNd7/QxqN/jAhYdW 7Ej3quWD2rdZM7V2ia+v3HWukyHF1FEK5J5+aMqk+d1uAVeV8Dyhcm+wbiBiBvh27aGT wp+a6oaXpfzQ2AXg9BMgtAL6XjHwbTlGGDKgv72mz7qHNgW3cIVY5qSZtT6gr5uJLmlb e2DcHV8fhOl4C/56rQ8p8I5aus+d/kuTUj3kIlbN5s66BzOvMtAvQWyKj9xu08eUVaZj Bwog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782315605; x=1782920405; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=bkYQNO5vR+uN9JdITatzFgUTsrAKtjKJYqqqqrE2vc8=; b=tPrntmh5cqg4bM/wcmW6SPATPD6aH9/7hNsrsbG9VuV08nSfiLhhPoWu2ydzZLfZXJ amW74RObLrsWaRslST4QiMkbKJXT+clri8MuyYxY9W++KjKrlUO/CVASjP6YKqLLfcRj 4paxEnoJiJfcy8gS7k0rEa8bilLa3y1CKQxc2bXFhFd/TW/Q3+w2UaHOcFvbLLOTqSMT c18GwjnU7TEtCkNMVlJZF3UY9+kw8F0qH9tBqrvvwa0elhDFc4Ak2nWDl4KQS5nLQ783 t2Q6DRaQ4UKJM5MS0CMDe0XcuzN01jtsDBWKvrvqEezlOgqnHC/zABkIHseCzUTTNhKk 9GLw== X-Forwarded-Encrypted: i=1; AFNElJ8/0KVH6+1TGQCnid+Nd+8JnqBE+6ToZ6bxEcrBNoN+e3fKYi3r7spr/o9WQwEZe5sh1NWQx9ZjrJGiRxc=@vger.kernel.org X-Gm-Message-State: AOJu0Yy0tTPwppJ5brroJISE3iY8IWu+s2yJuKC+laClskxMES4IUv2n FBc/VaD9VJqEwk54TwMXpRDDtq/oCHFOiAL1eIiR3U2qMKKvlFdNfwnnK4+PICaJRjM= X-Gm-Gg: AfdE7cmCteLA78SZ1HewbwPSDLB6ugZJ8GzGTjGVca5YCsW1eXpXad+AJOoYtn0/YQp XebFu01j0QUV0YX3JtiE7PKHTF+2/nu8lFnuOOtr2zBIQ/przJ2NmX7N2PJmQD70Q0Q1vIr8vlR hzlYgCDGlpUlRxAR3Kk/Y921s1Ktt837BiMVn6Dp3n68NsAtf2lFT9aqy0o6FZfLPus9chBytnq bX7bV46ibmIiWji3gUtQMR/53/Zb0xVqnuZ1rrVE2cIODnnG6PHOaP5AWNp7CpykwKdaBHyUoeu fePW/w7pnGHdvPi+LQ6KcMv1tI5FNYT8NBtrmaC/8e6wA6wWfSXxSbfHRsSAnGHkHVX4+G6jvPe 2dbcfo29WlcziBdJphfdlAErK+RCA6zAFl+LtJqzC27ZOrzxaitX74leGvwNxtIAivRFIVA== X-Received: by 2002:a05:600c:540f:b0:490:e196:6574 with SMTP id 5b1f17b1804b1-492608530d1mr57482155e9.13.1782315604315; Wed, 24 Jun 2026 08:40:04 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:306c:c2d:85d5:28d5]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49260915286sm160025075e9.1.2026.06.24.08.40.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2026 08:40:03 -0700 (PDT) From: "Denis V. Lunev" To: mst@redhat.com, david@kernel.org Cc: virtualization@lists.linux.dev, linux-kernel@vger.kernel.org, "Denis V. Lunev" Subject: [PATCH v2 5/4] virtio_balloon: warn on failed buffer add in stats_handle_request() Date: Wed, 24 Jun 2026 17:40:01 +0200 Message-ID: <20260624154001.2733242-1-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <549e5456-2b6c-48a5-abe5-ef5425c3f63c@kernel.org> References: <549e5456-2b6c-48a5-abe5-ef5425c3f63c@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Denis V. Lunev --- drivers/virtio/virtio_balloon.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 0866a8781f0b..454bbb77331d 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -445,6 +445,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); @@ -452,7 +453,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); } -- 2.53.0