lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <dd95348b-8711-4afe-af8a-62cfb1a1d9f1@web.de>
Date: Mon, 23 Sep 2024 11:16:26 +0200
From: Markus Elfring <Markus.Elfring@....de>
To: ntb@...ts.linux.dev, kernel-janitors@...r.kernel.org,
 Allen Hubbe <allenbh@...il.com>, Dave Jiang <dave.jiang@...el.com>,
 Jon Mason <jdmason@...zu.us>, Max Hawking <maxahawking@...nenkinder.org>,
 Serge Semin <fancer.lancer@...il.com>
Cc: LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH 2/2] ntb_perf: Use common error handling code in
 perf_copy_chunk()

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Mon, 23 Sep 2024 10:48:17 +0200

Add a jump target so that a bit of exception handling can be better reused
at the end of this function implementation.

Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
 drivers/ntb/test/ntb_perf.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/ntb/test/ntb_perf.c b/drivers/ntb/test/ntb_perf.c
index dfd175f79e8f..88c5192b81eb 100644
--- a/drivers/ntb/test/ntb_perf.c
+++ b/drivers/ntb/test/ntb_perf.c
@@ -816,10 +816,9 @@ static int perf_copy_chunk(struct perf_thread *pthr,
 	unmap->len = len;
 	unmap->addr[0] = dma_map_page(dma_dev, virt_to_page(src),
 		offset_in_page(src), len, DMA_TO_DEVICE);
-	if (dma_mapping_error(dma_dev, unmap->addr[0])) {
-		ret = -EIO;
-		goto err_free_resource;
-	}
+	if (dma_mapping_error(dma_dev, unmap->addr[0]))
+		goto e_io;
+
 	unmap->to_cnt = 1;

 	do {
@@ -829,10 +828,8 @@ static int perf_copy_chunk(struct perf_thread *pthr,
 			msleep(DMA_MDELAY);
 	} while (!tx && (try++ < DMA_TRIES));

-	if (!tx) {
-		ret = -EIO;
-		goto err_free_resource;
-	}
+	if (!tx)
+		goto e_io;

 	tx->callback = perf_dma_copy_callback;
 	tx->callback_param = pthr;
@@ -850,6 +847,8 @@ static int perf_copy_chunk(struct perf_thread *pthr,
 ret_check_tsync:
 	return likely(atomic_read(&pthr->perf->tsync) > 0) ? 0 : -EINTR;

+e_io:
+	ret = -EIO;
 err_free_resource:
 	dmaengine_unmap_put(unmap);

--
2.46.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ