From nobody Thu May 2 09:19:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603317028; cv=none; d=zohomail.com; s=zohoarc; b=FUJEB8sDVuYmO4xauf108u+SmAhvkzXC9jxHF1EtVGk2eXSz0pjsKqKDBPsxefQvIN3RIzUUH1iW7lgQwZlrQruZhw07rAQ10XKCNZr7E7DuzqTjMSuEOP6xAFebl3JUOoRePmq+nAPqEO45YOcYFQGT5heRyN645SJaFhkJWn8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603317028; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=ecEz12Eb/k+C+NKZECYliBDEOktQIjQGD5KTDGBDW4w=; b=iQ2CxbAk76+ImhoJStCZfugbwyRzbGhnMrcgBtSullYNpHDxR5F5I0tayLDy0j7lB8wqfCyJhwF2eN0tyGGztlmY6b5imykS4PWYG8OlFrsrHXbluVh5ij+J6czK+db3/CXIUON7TlhVidKEVGePeYqkU9ypTYsSmfiYmvPnbIg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1603317028659924.7145905423681; Wed, 21 Oct 2020 14:50:28 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-585-15X5Kf4iM9u4RvH70D0Ctg-1; Wed, 21 Oct 2020 17:50:25 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 87F0018A0728; Wed, 21 Oct 2020 21:50:16 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6169160C04; Wed, 21 Oct 2020 21:50:14 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B703B181A06B; Wed, 21 Oct 2020 21:50:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09LLoA37009545 for ; Wed, 21 Oct 2020 17:50:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0E49E5D9EF; Wed, 21 Oct 2020 21:50:10 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-113-132.phx2.redhat.com [10.3.113.132]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D42FC5D9DD for ; Wed, 21 Oct 2020 21:50:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603317027; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ecEz12Eb/k+C+NKZECYliBDEOktQIjQGD5KTDGBDW4w=; b=K4A4jrq2xGdhtoZv4+yKcUOxEQ3CCTnBWNbiqPVuznHQMXdXwSiUlyruLtL2Up/ukGAr/+ EAh1x5EO04J0lsOUj+g36YY7Nqq0E8ybL40EwCxS/ZsLVXChY8W6GUsQd1oEQHMdIl0x5v +yaZpFLusBa/r5mKa2Wr3q9QY2NWOIw= X-MC-Unique: 15X5Kf4iM9u4RvH70D0Ctg-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH] qemu: fix potential resource leak Date: Wed, 21 Oct 2020 16:50:06 -0500 Message-Id: <20201021215006.1936108-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Coverity reported a potential resource leak. While it's probably not a real-world scenario, the code could technically jump to cleanup between the time that vdpafd is opened and when it is used. Ensure that it gets cleaned up in that case. Signed-off-by: Jonathon Jongsma Reviewed-by: Laine Stump --- src/qemu/qemu_command.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 5c4e37bd9e..cbe7a6e331 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8135,6 +8135,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, addfdarg =3D g_strdup_printf("%s,opaque=3D%s", fdset, net->data.vdpa.devicepath); virCommandAddArgList(cmd, "-add-fd", addfdarg, NULL); + vdpafd =3D -1; } =20 if (chardev) @@ -8204,6 +8205,8 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, VIR_FREE(tapfdName); VIR_FREE(vhostfd); VIR_FREE(tapfd); + if (vdpafd >=3D 0) + VIR_FORCE_CLOSE(vdpafd); return ret; } =20 --=20 2.26.2