From nobody Tue Oct 7 03:38:53 2025 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; 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=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1587090963; cv=none; d=zohomail.com; s=zohoarc; b=C8O5r09eQq4LOVVXViZ70b/zhxCAiBlXH59NMq5k1ufBE6YBN+xKAC3/SCSLhFI9NWhh/9aDFFvDk1d6G6NnPjLpP1Q9e5oCHJTIOa5MQkv2CrgNLEkT3Ds9ECW2S8DtI0T52wufFxve+qfDpQgjd9du/tjjcseaEf/UOEXPGGs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587090963; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=R5KylAUBR3iNkf2gxL+t2DMN0j6I18HfKr7cGZyakHI=; b=lBT+AJK7ZeQbh12d8oaBVoyHUqeSWV2y5uM0EPktUTQzMdkrcse840F2LaF7ov4S98xPXdvLmiIzMrFevw0dvv1gsK150VR76eQ7Inp7rJ0wmYAbbR5vXcMYVqY/1YVbGjPdI4UfJjQiqfhQpKwI4jKjuZICDK95xE39ZnKoLLg= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 1587090963793245.97767982616267; Thu, 16 Apr 2020 19:36:03 -0700 (PDT) Received: from localhost ([::1]:41456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jPGrJ-0004Zx-F7 for importer@patchew.org; Thu, 16 Apr 2020 22:36:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41284) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jPGq9-0003aa-O8 for qemu-devel@nongnu.org; Thu, 16 Apr 2020 22:34:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jPGq8-0002Ep-Hk for qemu-devel@nongnu.org; Thu, 16 Apr 2020 22:34:49 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:55102) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jPGq8-0002Df-9h for qemu-devel@nongnu.org; Thu, 16 Apr 2020 22:34:48 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03H2XO6s003236 for ; Thu, 16 Apr 2020 22:34:47 -0400 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 30et5xr9tc-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 Apr 2020 22:34:47 -0400 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 17 Apr 2020 03:34:15 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 17 Apr 2020 03:34:13 +0100 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 03H2YeVg59441192 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Apr 2020 02:34:41 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D6FFE42045; Fri, 17 Apr 2020 02:34:40 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C3CE842042; Fri, 17 Apr 2020 02:34:40 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 17 Apr 2020 02:34:40 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 4958) id 7421CE02A3; Fri, 17 Apr 2020 04:34:40 +0200 (CEST) From: Eric Farman To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH v3 2/7] vfio-ccw: Refactor cleanup of regions Date: Fri, 17 Apr 2020 04:34:35 +0200 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200417023440.70514-1-farman@linux.ibm.com> References: <20200417023440.70514-1-farman@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 20041702-0008-0000-0000-0000037214B9 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20041702-0009-0000-0000-00004A93CEA0 Message-Id: <20200417023440.70514-3-farman@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-16_10:2020-04-14, 2020-04-16 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=916 priorityscore=1501 malwarescore=0 suspectscore=2 mlxscore=0 spamscore=0 impostorscore=0 adultscore=0 clxscore=1015 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004170019 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.156.1 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: Halil Pasic , Jason Herne , Eric Farman , Cornelia Huck , Jared Rossi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- Notes: v1-v2: - Add Conny's r-b 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 50cc2ec75c..ae9e396367 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -370,8 +370,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; @@ -384,15 +383,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.17.1