From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 B768A3BC687 for ; Wed, 24 Jun 2026 14:08:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782310137; cv=none; b=T218WRFFGnDSe7Fh5AD1uHwOvCBdw1rK7Cz4znGOcwkhfY+nrV6wmK4atjPjtSsxikLebBUErEhIvzuRlY13LGf+kTbPtlKzTe66SyyeO9bYZCi9m12kdKolrPzCY7jiCDViW71xnKjblIotn1LeAZG1aNvBljGCXWjGoMvXI8w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782310137; c=relaxed/simple; bh=igFQrv/PXQXqgtIh1JcAjAlWZZUf6i60J4mXCx0b60k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=br/zzEgGznWgyG91MR/l/baQc/XABHZe+9c+te2rDBIGgamMSSw3cPk8MRtu6vzgTS8iRj87io/+DSnZHcsAqVe+9SvPQPC6TR8CImSXlCzBU1tbqQ0SW9VteEYEqdKMTkuVg6BQ/9Y5rRh40YNhTImS3h9y7d7zlsRnYFa6Nf8= 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=ZM2iGcDb; arc=none smtp.client-ip=209.85.128.53 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="ZM2iGcDb" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-490b64c8311so13821055e9.3 for ; Wed, 24 Jun 2026 07:08:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1782310134; x=1782914934; 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=XCGKpS/WMN7c7W5tvYHxEGKLGq4sMQBRHoD49luMqTA=; b=ZM2iGcDbEbA6hbM4PD11SMK2VKrcpMqqM5dw8po8ZrHBfgc541gFaYoC9sYjFyGlv2 DUBo1YdVRCYkkb9huwbpzmr2sX0GLs882UoNhsYeb8BGVBIiThcL+ciWz8DyN/Kc2kOG jGE4lGeCvmO1QsykAJn/2Hg6hUGp+EmfW12nuSI9s+tWwnQKDATJSvX2c2q8lJ9YKqbs 833cfRU6YxDVGCLDGIfP37s3rm7QRmFas9VNKzHdER3s210402JtqUMBf1ujoUKRWSLj dAhMig7yjC49y4HwakoPx2I4WrfAjfqua3yT0pUZbLXgFwN0kTay9e19/cIco/4NSss0 Wk2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782310134; x=1782914934; 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=XCGKpS/WMN7c7W5tvYHxEGKLGq4sMQBRHoD49luMqTA=; b=iCnTxh3kYHyMeqtC4cqnV1BnrhrglnVjpsn3n6etrGu9ajD46hZN6eekZvz67CgM4w uKnp60beKGh7/9EWLRMU8odf7orArOKiiMoymeyWwaqwFenJ74ZjZmWEot3rB5/dM10n LE6VkOUJwrA8Q16q325DZ2sCU8W+rhBPhzfs/nqAfVBXCO/eZkgfhgW8GXLX9BzGDdvI HYE1lueJamcCh0aPRO5sWHVZHUnq4UmHMne96m9vtPhYNWnKHczONBZBMXad40aAcbdA Ln+3XFdQ9sRB9lVHshtv85mHrLxAL41mi5gm2AmFRxGKE7pdiYTEyfxzJSTAkGbd385q x87g== X-Forwarded-Encrypted: i=1; AFNElJ87u+uhjCvNJgRrgGazF2tdnX1dHVxWT+VW/cuvlA+7WfsfdJ5N+XBAlWJskrR65CXSsroma1Z9Qj6W1P0=@vger.kernel.org X-Gm-Message-State: AOJu0Ywhjql6NbQ0j+PqUogYDC2mRASxyC9lJ5T/j/+8Ioc8pYfHyrq+ DIpj32I/njiLgTerbJB55dknOy45Oi8DQC2S3Jskgt1QFNTNAV81lYDbc2/h2clVzQQ= X-Gm-Gg: AfdE7clNNiyglXC9RMFShe7kMEV3EDeWtruWKUELXg1yrCtvrD4O5eiPOwtFIH0jLCP ZowyTMyvN4hH43IGehpGpLcb28ShvOlnRBsBqqbRx57qD+cl9GT1/WyHUODfWsaMdWISvc2wr8P 68tHXmX/ofezHwa124A4KbtrdShlOYBZXN72ECoEYB1Ppxm2VHzufu82ZSXdRA0tC6gUUBxQOOi sSd1OkYzVvZ/nsetJ3h2AobCEwzDKEVAYpvfdfNB0PcWHiOyumBbG5m8i3VGkG6fyDx/1iNBOe4 BzhXHo9+YQhfjY3OdqiYIqyXrxk5HlRwYJybHinB21A5SndFl+SHVpVshe69kYUlB7amVEcjEhm SYA26lLaURJn5/0jkEckn36+whZwoEkDlqVMRGy6yo0cJd8itTn66I31LQolW8xGlMeZxrA== X-Received: by 2002:a05:600c:871b:b0:490:9588:bdae with SMTP id 5b1f17b1804b1-4926086d9bfmr51433695e9.18.1782310134163; Wed, 24 Jun 2026 07:08:54 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:306c:c2d:85d5:28d5]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4923fd1fa34sm519680275e9.5.2026.06.24.07.08.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2026 07:08:53 -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 4/4] virtio_balloon: warn on failed buffer add in tell_host() Date: Wed, 24 Jun 2026 16:08:46 +0200 Message-ID: <20260624140846.2616797-5-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260624140846.2616797-1-den@openvz.org> References: <20260624140846.2616797-1-den@openvz.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 tell_host() ignores the return value of virtqueue_add_outbuf() and goes on to kick the queue and wait_event() for the host's ack. The comment claims "We should always be able to add one buffer to an empty queue", but that does not hold once the virtqueue has been broken (e.g. on device shutdown): the add then fails with -EIO and the following wait_event() would block forever on a buffer the host can never return. Warn and bail out on failure, mirroring virtballoon_free_page_report(). Suggested-by: David Hildenbrand Signed-off-by: Denis V. Lunev --- drivers/virtio/virtio_balloon.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 26fc3c40d5b2..0866a8781f0b 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -184,16 +184,18 @@ static void tell_host(struct virtio_balloon *vb, struct virtqueue *vq) { struct scatterlist sg; unsigned int len; + int err; sg_init_one(&sg, vb->pfns, sizeof(vb->pfns[0]) * vb->num_pfns); /* We should always be able to add one buffer to an empty queue. */ - 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); /* When host has read buffer, this completes via balloon_ack */ wait_event(vb->acked, virtqueue_get_buf(vq, &len)); - } static int virtballoon_free_page_report(struct page_reporting_dev_info *pr_dev_info, -- 2.53.0