From nobody Wed Feb 11 05:28:55 2026 Received: from fhigh-a6-smtp.messagingengine.com (fhigh-a6-smtp.messagingengine.com [103.168.172.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA215238178 for ; Sat, 10 Jan 2026 01:39:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768009161; cv=none; b=G1K4mBbPgthyBqENt4ID3zOO+7e1uFLdUl0oiNI5xkG5CzsyCxK5a6Kfldf5sGTjjaQ2pMVqYdBeGfvN3uFKMtZ7VqCxbtwEORNLLeeusxnge7xRkY7TCj6DvEOKRVpWcYn/rmVY6AJRx8RipSi+LVR5wplEp7KCaOarzSALdmQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768009161; c=relaxed/simple; bh=Ol6igVD2G1M+M+pRlhUiF0UPa0x5bGP2EZkqTmp+62Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AMN1VVXjRu+AjasIBXAQ15N906nEYljV6+rkpQG9mg6Ah/hQEuJYv0u9Uamf7qlI2oTGaVFMcZQGTYVfl/EoF6UC5yFQSnxMERW207YTLtblNBYB2Qr8eucafiJpf18HER+8mXhjujBvjm8/fXoSc0oLahZvjvMPei1nuFUXlsE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp; spf=pass smtp.mailfrom=sakamocchi.jp; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b=EUsZfGgC; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=fre9FhZZ; arc=none smtp.client-ip=103.168.172.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sakamocchi.jp Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="EUsZfGgC"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="fre9FhZZ" Received: from phl-compute-09.internal (phl-compute-09.internal [10.202.2.49]) by mailfhigh.phl.internal (Postfix) with ESMTP id 2569514000B0; Fri, 9 Jan 2026 20:39:19 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-09.internal (MEProxy); Fri, 09 Jan 2026 20:39:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1768009159; x= 1768095559; bh=sVJaivj5Ky8I+xGb1QTAmBOCvix87KiE9SGbed9PRJo=; b=E UsZfGgCeltT7thGebvRanVJ+VnZhSdxzeL6Tx8EZbTwNqKTXx3KLeMZmOTno9S31 kSjcsO8gH4Qzb9tw/RapreydZwSs17tejKTp0hu6bZofh69Uo/esssnUc+IH2yvE MF08Cl5S5LRO4MMlm6CU6awrUlFz3zghd/foy8tW9fE/eXy3U4VnjeFPhrqiW50U Cq3Yj/mf+/EYnIFpdkLsf3LlW3ohj/2n8mH+rpU1b2QQ+VSG5+t3juWyitaK+nRp 596pJP//pSmvTMgdukKKaHwWvH9vs/G+nGKtDwRak7x3+feTgxo2u2Yd7vo86GoH Ht+njGHUKUgj6ypYXEFLA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1768009159; x=1768095559; bh=s VJaivj5Ky8I+xGb1QTAmBOCvix87KiE9SGbed9PRJo=; b=fre9FhZZ3MGnj72Ge wx0xRwA06Gc3XCyAYuSallRcdaI2BNau9wlJfDRnzaaVj7/jzFZxxGN05txKUgPa hYm7wR7smd3j1Ux38f4ZrGFQwN0du3IfPiFQxxE/zQu4cxvJ6LuJO5Idh2Kpmmow twC5MSWZ1hP5OgAHROFLOl6uV2+7NPfIMqwzm1QIHXzSRUSC82HrWLzO1+8kE3jB Ratm6GZ6eK8BwyveT5hlt/Zl1WSfYVIfm/5oT43ovKUt/ONNv2zzhgcUJRuC+nuH T/+rJTFEYwH8NsSl+X8gp0HtBJuB2Kh1ttPlUUuwr1xQFIr/sPSFkCwLpkp/pR2q juqyQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdduuddtfeelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtkeertd ertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghkrghs hhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgjeeuvd fguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushhtvghr ufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrg hkrghmohgttghhihdrjhhppdhnsggprhgtphhtthhopeefpdhmohguvgepshhmthhpohhu thdprhgtphhtthhopehlihhnuhigudefleegqdguvghvvghlsehlihhsthhsrdhsohhurh gtvghfohhrghgvrdhnvghtpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgv rhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepjhhgghesnhhvihguihgrrdgtohhm X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 9 Jan 2026 20:39:18 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org, jgg@nvidia.com Subject: [PATCH 3/8] firewire: core: code refactoring with cleanup function for isoc pages Date: Sat, 10 Jan 2026 10:39:06 +0900 Message-ID: <20260110013911.19160-4-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260110013911.19160-1-o-takashi@sakamocchi.jp> References: <20260110013911.19160-1-o-takashi@sakamocchi.jp> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This commit refactors the implementation to allocate pages for isochronous DMA contexts with cleanup function. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-iso.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/firewire/core-iso.c b/drivers/firewire/core-iso.c index a67493862c85..e678ffba5de2 100644 --- a/drivers/firewire/core-iso.c +++ b/drivers/firewire/core-iso.c @@ -30,26 +30,29 @@ =20 int fw_iso_buffer_alloc(struct fw_iso_buffer *buffer, int page_count) { + struct page **page_array __free(kfree) =3D kcalloc(page_count, sizeof(pag= e_array[0]), GFP_KERNEL); int i; =20 - buffer->page_count =3D 0; - buffer->page_count_mapped =3D 0; - buffer->pages =3D kmalloc_array(page_count, sizeof(buffer->pages[0]), - GFP_KERNEL); - if (buffer->pages =3D=3D NULL) + if (!page_array) return -ENOMEM; =20 - for (i =3D 0; i < page_count; i++) { - buffer->pages[i] =3D alloc_page(GFP_KERNEL | GFP_DMA32 | __GFP_ZERO); - if (buffer->pages[i] =3D=3D NULL) + for (i =3D 0; i < page_count; ++i) { + struct page *page =3D alloc_page(GFP_KERNEL | GFP_DMA32 | __GFP_ZERO); + + if (!page) break; + page_array[i] =3D page; } - buffer->page_count =3D i; + if (i < page_count) { - fw_iso_buffer_destroy(buffer, NULL); + while (i-- > 0) + __free_page(page_array[i]); return -ENOMEM; } =20 + buffer->page_count =3D page_count; + buffer->pages =3D no_free_ptr(page_array); + return 0; } =20 @@ -104,11 +107,14 @@ void fw_iso_buffer_destroy(struct fw_iso_buffer *buff= er, dma_unmap_page(card->device, address, PAGE_SIZE, buffer->direction); } - for (i =3D 0; i < buffer->page_count; i++) - __free_page(buffer->pages[i]); =20 - kfree(buffer->pages); - buffer->pages =3D NULL; + if (buffer->pages) { + for (int i =3D 0; i < buffer->page_count; ++i) + __free_page(buffer->pages[i]); + kfree(buffer->pages); + buffer->pages =3D NULL; + } + buffer->page_count =3D 0; buffer->page_count_mapped =3D 0; } --=20 2.51.0