From nobody Mon Nov 23 04:32:35 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1793779840; cv=none; d=zohomail.com; s=zohoarc; b=eNkouY/Xx9IgcFwKsl7LcfjYgUzeinoY1g82zdb6thZiC4SATiNpY236h1NRhOu2WIDt2QLMcbjnFy85/viflBqDv+I/P8tqjnPXuCWfluZSlBqzZ+sgPmmulVDtfrxik4SfQut1p4B5NmlFPCHF0GTG2WUbfFGgnCSvUK8ZV+w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793779840; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PSmy8jzFUS9WxzXBQPmZHSDVhGXtMsL0D/UQGilfZmo=; b=W18cjnjhd4P4jRQyYS23LJXD3dvvnVAKy9v2xrbVq3rV7qN7d/+ri6q0ex68dGP9O0cm7IxfRrneP6agLoFwf3YRE08T1oftzQndd6DbsMtrx5uViyS99OlmyCik2ncSA1dKYA1uF3RNTwtSORIur374M4/4D/4+Eo/H85yFS9M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793779839844671.8717493849293; Wed, 4 Nov 2026 00:10:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOW4F-0006Vo-DR; Wed, 04 Nov 2026 03:09:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOW4B-0006VY-NN for qemu-devel@nongnu.org; Wed, 04 Nov 2026 03:09:57 -0500 Received: from forwardcorp2d.mail.yandex.net ([2a02:6b8:c41:1300:1:45:d181:df02]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOW49-0001NL-IN for qemu-devel@nongnu.org; Wed, 04 Nov 2026 03:09:55 -0500 Received: from mail-nwsmtp-smtp-corp-main-68 (mail-nwsmtp-smtp-corp-main-68.yp-c.yandex.net) by forwardcorp2d.mail.yandex.net (postfix) with ESMTPS id E9A9A80C2B; Wed, 04 Nov 2026 11:09:44 +0300 (MSK) Received: from dtalexundeer-nx.yandex-team.ru by mail-nwsmtp-smtp-corp-main-68 with ESMTPSA id d9HpgM5agCg0-bxk21wZr; Wed, 04 Nov 2026 11:09:44 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1793779784; bh=PSmy8jzFUS9WxzXBQPmZHSDVhGXtMsL0D/UQGilfZmo=; h=Message-Id:Date:Cc:Subject:To:From; b=mHL1wxtbIVCsCjn+JS3x3rF8oA24EsZrQdTVCqjPAa3vJHDzwbs8AFQFzQce7gTa1 c8gPAPALpoCj1JEXEAjoLLxtjiqoIIReiNLfCa+KhhGWDJKT5Tulca2NdfRP/tkD7k X1tt++yBrYI/2wXnkFqhkWPQyUsRL9wuzJLpM9X0= Authentication-Results: mail-nwsmtp-smtp-corp-main-68; dkim=pass header.i=@yandex-team.ru From: Alexandr Moshkov To: qemu-devel@nongnu.org Cc: Stefano Garzarella , Stefan Hajnoczi , "yc-core@yandex-team.ru" , "Dr . David Alan Gilbert" , "Michael S. Tsirkin" , virtio-fs@lists.linux.dev, Alexandr Moshkov Subject: [PATCH] vhost-user-fs: fix virtqueue array leak on realize failure Date: Wed, 4 Nov 2026 13:09:39 +0500 Message-Id: <20261104080939.439160-1-dtalexundeer@yandex-team.ru> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a02:6b8:c41:1300:1:45:d181:df02; envelope-from=dtalexundeer@yandex-team.ru; helo=forwardcorp2d.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1793779842857158500 Content-Type: text/plain; charset="utf-8" On failure, vhost_dev_init() clears vhost_dev, so the error path frees NULL instead of the virtqueue array. Save the pointer locally and use it to free the array on failure. Fixes: 98fc1ada4cf7 ("virtio: add vhost-user-fs base device") Signed-off-by: Alexandr Moshkov --- hw/virtio/vhost-user-fs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index 0d8842817a..9b33fe13bb 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -198,6 +198,7 @@ static void vuf_device_realize(DeviceState *dev, Error = **errp) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VHostUserFS *fs =3D VHOST_USER_FS(dev); + struct vhost_virtqueue *vhost_vqs; unsigned int i; size_t len; int ret; @@ -255,7 +256,8 @@ static void vuf_device_realize(DeviceState *dev, Error = **errp) =20 /* 1 high prio queue, plus the number configured */ fs->vhost_dev.nvqs =3D 1 + fs->conf.num_request_queues; - fs->vhost_dev.vqs =3D g_new0(struct vhost_virtqueue, fs->vhost_dev.nvq= s); + vhost_vqs =3D g_new0(struct vhost_virtqueue, fs->vhost_dev.nvqs); + fs->vhost_dev.vqs =3D vhost_vqs; ret =3D vhost_dev_init(&fs->vhost_dev, &fs->vhost_user, VHOST_BACKEND_TYPE_USER, 0, errp); if (ret < 0) { @@ -272,7 +274,7 @@ err_virtio: } g_free(fs->req_vqs); virtio_cleanup(vdev); - g_free(fs->vhost_dev.vqs); + g_free(vhost_vqs); } =20 static void vuf_device_unrealize(DeviceState *dev) --=20 2.34.1