From nobody Mon Nov 25 22:21:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1592309289; cv=none; d=zohomail.com; s=zohoarc; b=nPpcQAuIMNykjp8nlGNwSfTPfm0PmqnVCwFFw2Vz/1hifBL1tdvbGj24VXGF5G5aJvp3rv2qEz53PxMruf33pSXAlZ/UC9+k6PrT3zlLtml6Ke42+9jhQpjxWbS9RHfOahKSNC+8eGA5szQrRbrj6OM6c0znEH44MChyBRzo9r0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592309289; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DhvBvdEBQUPLTM0mddRTAuAmkHwfXmcVb3cnAEAi5zc=; b=GEdNeVuRC1Y5hKB1t6WU0O0YTyA7cbBbeTtSVPY035CgBLHW2MJ64WNd53kt3iGwQxVFLhTpW9swiQPU2DOc2Ja7i7I1XooUQ+aATcMHht0/bfFvIm4/as4bo+MhZ16wZwXke9GPvP9mZnYszeh/rZOnWHbJtpjbyQoM4vr3DLs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1592309289700381.77598966626795; Tue, 16 Jun 2020 05:08:09 -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-77-wrI-RZ8WOtO_nCHKCY_g2Q-1; Tue, 16 Jun 2020 08:07:44 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5F0B3100A623; Tue, 16 Jun 2020 12:07:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3991A7FE95; Tue, 16 Jun 2020 12:07:37 +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 E792787425; Tue, 16 Jun 2020 12:07:36 +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 05GC7JrB001156 for ; Tue, 16 Jun 2020 08:07:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 96E635D9DA; Tue, 16 Jun 2020 12:07:19 +0000 (UTC) Received: from unknown0050b6a41c42.attlocal.com (ovpn-112-147.phx2.redhat.com [10.3.112.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 57F905D9D5 for ; Tue, 16 Jun 2020 12:07:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592309288; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=DhvBvdEBQUPLTM0mddRTAuAmkHwfXmcVb3cnAEAi5zc=; b=fVBrz89h7N0bl+PJ7AIZTFZqqiek15jhXcnPVMZH7YqYCrzWmJJrIZeKQAE6HWCJrGzPpr EBV5GuBDwHlH9X1mDTYj1UTyIhA99JYEOJBmc6xC/VTXsDX6nn2mgSHv85yr9n2J8QlvwR DKb3BEQjKp2WB0TK+jdIwGW5wtyQv88= X-MC-Unique: wrI-RZ8WOtO_nCHKCY_g2Q-1 From: John Ferlan To: libvir-list@redhat.com Subject: [PATCH 9/9] util: Avoid using wrong free function Date: Tue, 16 Jun 2020 08:07:10 -0400 Message-Id: <20200616120710.2628344-10-jferlan@redhat.com> In-Reply-To: <20200616120710.2628344-1-jferlan@redhat.com> References: <20200616120710.2628344-1-jferlan@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.15 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" Since 1e2ae2e31, changes to use the automagic free logic didn't take into account that one path uses posix_memalign and the other uses VIR_ALLOC_N - the former requires using VIR_FREE() and not g_free() to free the memory. Found by Coverity. Signed-off-by: John Ferlan --- src/util/iohelper.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/util/iohelper.c b/src/util/iohelper.c index 342bae229b..64b7a13f61 100644 --- a/src/util/iohelper.c +++ b/src/util/iohelper.c @@ -45,7 +45,11 @@ static int runIO(const char *path, int fd, int oflags) { +#if HAVE_POSIX_MEMALIGN + void *base =3D NULL; /* Location to be freed */ +#else g_autofree void *base =3D NULL; /* Location to be freed */ +#endif char *buf =3D NULL; /* Aligned location within base */ size_t buflen =3D 1024*1024; intptr_t alignMask =3D 64*1024 - 1; @@ -168,6 +172,9 @@ runIO(const char *path, int fd, int oflags) ret =3D 0; =20 cleanup: +#if HAVE_POSIX_MEMALIGN + VIR_FREE(base); +#endif if (VIR_CLOSE(fd) < 0 && ret =3D=3D 0) { virReportSystemError(errno, _("Unable to close %s"), path); --=20 2.25.4