From nobody Fri Mar 29 10:20:50 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=1631432302; cv=none; d=zohomail.com; s=zohoarc; b=Gp+NeAEzcwBiezFHH+Mde3QuzkHIFmfofNagqzprXJ6RqGmT9UEsm4bYCpzLtnEZF2L4Vrh+U6hBAYIZd43PKpECrvyu3IMPwp/Wp8TAilBqC5vhXd8iXk/CTUsg4dGKkhJ+cAuxYVyC95idiTZXbzac5KjVOXyINWMXIqaSReg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631432302; 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=yASy42dUFNfKyjCPgcyxlLCZeygneM2q68K4w9iAowU=; b=Opt/dpnYoHI3TzcPJBtig/Yi0fBTsthuVykB9NrqIywMSAtQoFzL1aPsWSDo5gQ0cVTKSAhCPN+sx4lm+gM7iHoSIxmBs8087Or5EiU+xq6ryAnJJqVoYDnwJJPK27tBcTpJuShudYJ2VJsBle0We7xZCgCYl63LwZ8p3xcV69A= 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) 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 1631432302070363.5244859702967; Sun, 12 Sep 2021 00:38:22 -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-205-6opveRE2MbKrGwHQMtQsjw-1; Sun, 12 Sep 2021 03:38:19 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DE5241084683; Sun, 12 Sep 2021 07:38:13 +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 CCD4E60583; Sun, 12 Sep 2021 07:38:09 +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 AE2321805986; Sun, 12 Sep 2021 07:38:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18C7YpRM018625 for ; Sun, 12 Sep 2021 03:34:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3F29277701; Sun, 12 Sep 2021 07:34:51 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id B20152B399 for ; Sun, 12 Sep 2021 07:34:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631432301; 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=yASy42dUFNfKyjCPgcyxlLCZeygneM2q68K4w9iAowU=; b=AYbjzHEhH66KBYAAo4xihs5uhpLHDEixQViJYTrXDH0Sas6KkQIttY7xOerAewrsJr+Nos urpZcbcEllDfiyWBhtWj3ou/jJP4aaYU+9ufWgKe2woT8ca+uB9RPhR2nzMRMCCTIXwF4R pskQCcT7f71R3P8PdqOWIct4LJwQu0Q= X-MC-Unique: 6opveRE2MbKrGwHQMtQsjw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] node_device_conf: Don't prealloc @vfs in virNodeDeviceGetPCISRIOVCaps() Date: Sun, 12 Sep 2021 09:34:44 +0200 Message-Id: <429023dda5213d9415c5f7a8d58e6ad29242d9ed.1631432078.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.11 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) X-ZM-MESSAGEID: 1631432304310100001 Content-Type: text/plain; charset="utf-8" The array of virtual functions @vfs in virNodeDeviceGetPCISRIOVCaps() is allocated twice: the first time during its declaration and the second time inside virPCIGetVirtualFunctions() which leads to a memleak: =3D=3D16691=3D=3D 1,128 bytes in 47 blocks are definitely lost in loss reco= rd 1,771 of 1,803 =3D=3D16691=3D=3D at 0x4844CC1: calloc (vg_replace_malloc.c:1117) =3D=3D16691=3D=3D by 0x4E50070: g_malloc0 (in /usr/lib64/libglib-2.0.so.= 0.6800.3) =3D=3D16691=3D=3D by 0x4A7B034: virNodeDeviceGetPCISRIOVCaps (node_devic= e_conf.c:2649) =3D=3D16691=3D=3D by 0x4A7B5E2: virNodeDeviceGetPCIDynamicCaps (node_dev= ice_conf.c:2762) =3D=3D16691=3D=3D by 0xA7F6E18: udevProcessPCI (node_device_udev.c:418) Fixes: c97518d9b833a607f29b9bb02e3fbe74c011c088 Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/node_device_conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index b4c1acb6a5..9bbff97ffd 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -2646,7 +2646,7 @@ static int virNodeDeviceGetPCISRIOVCaps(const char *sysfsPath, virNodeDevCapPCIDev *pci_dev) { - g_autoptr(virPCIVirtualFunctionList) vfs =3D g_new0(virPCIVirtualFunct= ionList, 1); + g_autoptr(virPCIVirtualFunctionList) vfs =3D NULL; size_t i; int ret; =20 --=20 2.32.0