From nobody Sat Jul 4 21:04:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1782913976; cv=none; d=zohomail.com; s=zohoarc; b=BwRYBbX2EZ68b7VMp7qyJ68i8s2it53Jp8gfjhUKHBTMbY4mqmYKhdrZ9ubPMlccymKK7wkzJklW6JSstiw1Rk6sqatsARqESxDe6i+tcVstk2KF/fs64ri8k8qu7H58bIMDqE1IZsHPrOSwbJipufdGbrj/z+i21fFFTUwHA/g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782913976; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xl3e4suKSPl7CWk+sb8bPatN3ANB8eUSjC46flYftEE=; b=JRXVr/EwHkaHaM/kQArPg+gqXaQff4VDRjTp6Qy8upytfaAHmzQpvJaLjkGFR4iyfByQtqxm05yK1Iqvgzaorjh2jz0aHq61zdvcQtxEkPEd6xr9LfDUaqlsKRmoO77B2jvyNwWh5W3BQ6iA6nCDw4OAKjOwrYIrKec7Ru0XKlU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1782913976495175.02604270033316; Wed, 1 Jul 2026 06:52:56 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1349989.1607573 (Exim 4.92) (envelope-from ) id 1wevMi-0007I8-4H; Wed, 01 Jul 2026 13:52:36 +0000 Received: by outflank-mailman (output) from mailman id 1349989.1607573; Wed, 01 Jul 2026 13:52:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wevMi-0007I1-0D; Wed, 01 Jul 2026 13:52:36 +0000 Received: by outflank-mailman (input) for mailman id 1349989; Wed, 01 Jul 2026 13:52:34 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wevMg-0007Hs-SP for xen-devel@lists.xenproject.org; Wed, 01 Jul 2026 13:52:34 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wevMg-00B58B-5Z for xen-devel@lists.xenproject.org; Wed, 01 Jul 2026 15:52:34 +0200 Received: from [10.42.69.8] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a451b9f-2eae-0a2a0a5409dd-0a2a45088f56-6 for ; Wed, 01 Jul 2026 15:52:34 +0200 Received: from [209.85.221.46] (helo=mail-wr1-f46.google.com) by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a451ba1-edec-0a2a45080019-d155dd2ef026-3 for ; Wed, 01 Jul 2026 15:52:33 +0200 Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-4763b0c1dcdso798018f8f.2 for ; Wed, 01 Jul 2026 06:52:33 -0700 (PDT) Received: from localhost.localdomain (host-78-146-248-75.as13285.net. [78.146.248.75]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4756636ce7esm18672970f8f.23.2026.07.01.06.52.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2026 06:52:32 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=citrix.com header.i="@citrix.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1782913953; x=1783518753; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=xl3e4suKSPl7CWk+sb8bPatN3ANB8eUSjC46flYftEE=; b=DknmK2MOxsjafHEumZJq0pswxDGKZal8eKAmaAM6Kh+0PPVO8c+VKgALVXbT3Kjx+3 UkoO5E+XfDUsdt4jCTEAK/nA3YyRYzWHcRPP9WYWXc9rWRzEB8ijM5+FXR9WIzjxG5wU Qn4mWx2Um0+nx0w1uFYdm7upvJtPrftqqrSIY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782913953; x=1783518753; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=xl3e4suKSPl7CWk+sb8bPatN3ANB8eUSjC46flYftEE=; b=DipnSc9Mz/vVvPnMj/QpRqmaUAWIh+v1g0J4CaeDmRKc1+lDglYVdFVAF0pgcX0szP 5ugHrHrZa4BRriAeOA+Jbuvjy29FEgR8XCXZXr5KrBDZif1+aAW/x2rgpx77KxDbPysR tE2trzBFoTjTOon4JRe57g3AKISIQjqBFI9tFupAqEJt0ut1uAoCko9phKs938jILWLJ Ugo9ax11HEZzwANh65G+809TmuNbHsSU4sR0mwaf3tPEcxmLCFZVLB5EysO0Ij1bs538 zMPp2015B8v1cf4dv+txeZ0gae0/9TzLQi3amhowVnwocVnmfUMWOJZPNsbHYYS2BUdb LDAQ== X-Gm-Message-State: AOJu0Yy7JsPgpWEWZM8HMimZv4reNnLEc86KDQBA4luE/7chSPwNQiyx FSxjuBTXAkWOvIWFxz0hcecAjtmxnUrvJgt9gBl7Uncp46gTeTgnMK85CEfwY9bDT+FG1G4nFiA NAQB1 X-Gm-Gg: AfdE7cm1A2pEIVp1KfLTg26BeFk4DReA8wBmxoi/fG5t8kHo/T88Wnje93SGDqEqzuH HhXt7JpQa/FYlS5/y0u+T9YsDg1N9nfbs1tFbefUtlOiSBndHUp9y0Gl5N1r62FK8psziU0Pnyr 6YTFBpN3jYjFLTSf2OrmkGxx4Izc6cYT99k9wf9jk4D9bHjxL3E1PPA2a3lNWnzi6UQs/KlwHJw sR60CFD2ZsCGwhqMGySKOzC2joYUEHDIQJK900IyUw1h06EcUAO+xdq7yqyGvbTFiBUBQCCz+5g NeVtnBD5rqV8jYO9JAJyWKParS/OTYdGrJC2iXG7sY2awa9JYBq2m4fXOe3jENhqSFSCyLAfIT9 KmjT1t2ZAQw8DLJ2p3KfvLTmye+IeRYF9nnYY+jXJl5SwFFBMrt7pRJcT+W+1Swz2Z/4eOS1RRD eW5q6FVv+Nsn1VbV0qwz+q4jgxR21kq9KgsdKGN8A9vyl7K4dhFJtf1u04bLUMb9ixluKtU0AcH Q== X-Received: by 2002:adf:ed42:0:b0:477:80fa:f44d with SMTP id ffacd0b85a97d-477b5677843mr793528f8f.40.1782913952815; Wed, 01 Jul 2026 06:52:32 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Anthony PERARD , Frediano Ziglio Subject: [PATCH v6 1.9/16] libs/guest: Allocate rec_pfns earlier in write_batch() Date: Wed, 1 Jul 2026 14:52:30 +0100 Message-Id: <20260701135230.794306-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260619130501.272832-3-frediano.ziglio@citrix.com> References: <20260619130501.272832-3-frediano.ziglio@citrix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-c1860d/1782913954-A2D3B3FC-A57FC2C9/0/0 X-purgate-type: clean X-purgate-size: 2133 X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1782913977483158500 Content-Type: text/plain; charset="utf-8" For reasons which escape me, rec_pfns are allocated separately to the rest = of the batch allocations. Allocate them all together. This will allow for future simplifications to = be performed in an incremental mannor. No functional change. Signed-off-by: Andrew Cooper --- CC: Anthony PERARD CC: Frediano Ziglio --- tools/libs/guest/xg_sr_save.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/tools/libs/guest/xg_sr_save.c b/tools/libs/guest/xg_sr_save.c index fdbceab52e46..69fe991a8113 100644 --- a/tools/libs/guest/xg_sr_save.c +++ b/tools/libs/guest/xg_sr_save.c @@ -116,8 +116,10 @@ static int write_batch(struct xc_sr_context *ctx) local_pages =3D calloc(nr_pfns, sizeof(*local_pages)); /* iovec[] for writev(). */ iov =3D malloc((nr_pfns + 4) * sizeof(*iov)); + /* page_data record PFNs list */ + rec_pfns =3D malloc(nr_pfns * sizeof(*rec_pfns)); =20 - if ( !mfns || !types || !errors || !guest_data || !local_pages || !iov= ) + if ( !mfns || !types || !errors || !guest_data || !local_pages || !iov= || !rec_pfns ) { ERROR("Unable to allocate arrays for a batch of %u pages", nr_pfns); @@ -208,14 +210,6 @@ static int write_batch(struct xc_sr_context *ctx) } } =20 - rec_pfns =3D malloc(nr_pfns * sizeof(*rec_pfns)); - if ( !rec_pfns ) - { - ERROR("Unable to allocate %zu bytes of memory for page data pfn li= st", - nr_pfns * sizeof(*rec_pfns)); - goto err; - } - hdr.count =3D nr_pfns; =20 rec.length =3D sizeof(hdr); @@ -264,11 +258,11 @@ static int write_batch(struct xc_sr_context *ctx) rc =3D ctx->save.nr_batch_pfns =3D 0; =20 err: - free(rec_pfns); if ( guest_mapping ) xenforeignmemory_unmap(xch->fmem, guest_mapping, nr_pages_mapped); for ( i =3D 0; local_pages && i < nr_pfns; ++i ) free(local_pages[i]); + free(rec_pfns); free(iov); free(local_pages); free(guest_data); --=20 2.39.5