From nobody Mon Feb 9 12:27:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1592495014; cv=none; d=zohomail.com; s=zohoarc; b=ALn0uiZmrInlFSvrQpzPwVYNDbRkzPzOvjh3veuAxnN5ET8A3/SPMy46YUN5w1xfRKndqgUo/pcsrSAS2b6rfiQb59wqrJtZ2eBPr+J9OXAjOFDn5VRdf+nrDC0JdhLvJ0g4P6gtUzFxbISmP4Vq8pOOKNFl38XvwjvOjHlATzI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592495014; h=Content-Type:Content-Transfer-Encoding:Cc: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=LHMfTnxDPPj1KzVGwd4eEomp/i7Q3J54bGl21OXZsg4=; b=jVEE2pj8EoVPp1CN8EcUAHGF5UO7cj3nzIH9d5gG2ERHW0QTMYPyDzSzqDY8rbY6+IpxQCw2epTmiaf1oLZ7CMWbfMevLDVo9AAiFqS7tYJYS6g6UUizrDd1pxB/X4n+LpwXraVXjMuhJ6GQJCWts6+6hhj1ELd9UIbmVjKZW38= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592495014967765.4571307458348; Thu, 18 Jun 2020 08:43:34 -0700 (PDT) Received: from localhost ([::1]:53132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlwh0-0005pr-2d for importer@patchew.org; Thu, 18 Jun 2020 11:43:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60576) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlwdD-0000of-A5 for qemu-devel@nongnu.org; Thu, 18 Jun 2020 11:39:11 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:51081 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jlwdB-0008RI-Lf for qemu-devel@nongnu.org; Thu, 18 Jun 2020 11:39:10 -0400 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-410-qG_YIQAkPFCA_25OBAhYiQ-1; Thu, 18 Jun 2020 11:39:04 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6155B8BFB41; Thu, 18 Jun 2020 15:39:03 +0000 (UTC) Received: from localhost (ovpn-113-9.ams2.redhat.com [10.36.113.9]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 093385D9D3; Thu, 18 Jun 2020 15:39:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592494746; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LHMfTnxDPPj1KzVGwd4eEomp/i7Q3J54bGl21OXZsg4=; b=g+53UUJZocfGQwoUE2o8uY1b9abbqcSX+pjT9XWVPVAovXM8DlGFOcKzUN8MCo6PV9UvbL L3WvI1j47bbGK7T59QkQ6AZQtr3BENWHlsZVZLTPvsiir0ZG2ImEIfLkvqI9SaelUjrAUe tpwUBAeeyw0o5HbxT8tL1OMvJL/KFy4= X-MC-Unique: qG_YIQAkPFCA_25OBAhYiQ-1 From: Cornelia Huck To: Peter Maydell Subject: [PULL 2/7] vfio-ccw: Refactor cleanup of regions Date: Thu, 18 Jun 2020 17:38:49 +0200 Message-Id: <20200618153854.271723-3-cohuck@redhat.com> In-Reply-To: <20200618153854.271723-1-cohuck@redhat.com> References: <20200618153854.271723-1-cohuck@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=cohuck@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/18 01:32:18 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eric Farman , qemu-s390x@nongnu.org, Cornelia Huck , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Eric Farman While we're at it, add a g_free() for the async_cmd_region that is the last thing currently created. g_free() knows how to handle NULL pointers, so this makes it easier to remember what cleanups need to be performed when new regions are added. Signed-off-by: Eric Farman Reviewed-by: Cornelia Huck Message-Id: <20200505125757.98209-3-farman@linux.ibm.com> Signed-off-by: Cornelia Huck --- hw/vfio/ccw.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 63406184d226..ca06213d0375 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -363,8 +363,7 @@ static void vfio_ccw_get_region(VFIOCCWDevice *vcdev, E= rror **errp) vcdev->io_region_size =3D info->size; if (sizeof(*vcdev->io_region) !=3D vcdev->io_region_size) { error_setg(errp, "vfio: Unexpected size of the I/O region"); - g_free(info); - return; + goto out_err; } =20 vcdev->io_region_offset =3D info->offset; @@ -377,15 +376,20 @@ static void vfio_ccw_get_region(VFIOCCWDevice *vcdev,= Error **errp) vcdev->async_cmd_region_size =3D info->size; if (sizeof(*vcdev->async_cmd_region) !=3D vcdev->async_cmd_region_= size) { error_setg(errp, "vfio: Unexpected size of the async cmd regio= n"); - g_free(vcdev->io_region); - g_free(info); - return; + goto out_err; } vcdev->async_cmd_region_offset =3D info->offset; vcdev->async_cmd_region =3D g_malloc0(info->size); } =20 g_free(info); + return; + +out_err: + g_free(vcdev->async_cmd_region); + g_free(vcdev->io_region); + g_free(info); + return; } =20 static void vfio_ccw_put_region(VFIOCCWDevice *vcdev) --=20 2.25.4