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] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241001-cleanup-if_not_cond_guard-v1-3-7753810b0f7a@baylibre.com>
Date: Tue, 01 Oct 2024 17:30:20 -0500
From: David Lechner <dlechner@...libre.com>
To: Peter Zijlstra <peterz@...radead.org>, 
 Dan Williams <dan.j.williams@...el.com>, 
 Linus Torvalds <torvalds@...ux-foundation.org>, 
 Jonathan Cameron <jic23@...nel.org>
Cc: Nuno Sá <nuno.sa@...log.com>, 
 Michael Hennerich <michael.hennerich@...log.com>, 
 linux-kernel@...r.kernel.org, linux-iio@...r.kernel.org, 
 linux-cxl@...r.kernel.org, Ira Weiny <ira.weiny@...el.com>, 
 "Fabio M. De Francesco" <fabio.maria.de.francesco@...ux.intel.com>, 
 David Lechner <dlechner@...libre.com>
Subject: [PATCH 3/3] cxl/region: Use cond_guard() in show_targetN()

Use if_not_cond_guard() to avoid goto and rc variable in the
show_targetN() function.

Suggested-by: Dan Williams <dan.j.williams@...el.com>
Suggested-by: Ira Weiny <ira.weiny@...el.com>
Co-developed-by: Fabio M. De Francesco <fabio.maria.de.francesco@...ux.intel.com>
Signed-off-by: Fabio M. De Francesco <fabio.maria.de.francesco@...ux.intel.com>
Signed-off-by: David Lechner <dlechner@...libre.com>
---
 drivers/cxl/core/region.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index e701e4b04032..e7c0221edeae 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /* Copyright(c) 2022 Intel Corporation. All rights reserved. */
+#include <linux/cleanup.h>
 #include <linux/memregion.h>
 #include <linux/genalloc.h>
 #include <linux/device.h>
@@ -770,28 +771,21 @@ static size_t show_targetN(struct cxl_region *cxlr, char *buf, int pos)
 {
 	struct cxl_region_params *p = &cxlr->params;
 	struct cxl_endpoint_decoder *cxled;
-	int rc;
 
-	rc = down_read_interruptible(&cxl_region_rwsem);
-	if (rc)
-		return rc;
+	if_not_cond_guard(rwsem_read_intr, &cxl_region_rwsem)
+		return -EINTR;
 
 	if (pos >= p->interleave_ways) {
 		dev_dbg(&cxlr->dev, "position %d out of range %d\n", pos,
 			p->interleave_ways);
-		rc = -ENXIO;
-		goto out;
+		return -ENXIO;
 	}
 
 	cxled = p->targets[pos];
 	if (!cxled)
-		rc = sysfs_emit(buf, "\n");
-	else
-		rc = sysfs_emit(buf, "%s\n", dev_name(&cxled->cxld.dev));
-out:
-	up_read(&cxl_region_rwsem);
+		return sysfs_emit(buf, "\n");
 
-	return rc;
+	return sysfs_emit(buf, "%s\n", dev_name(&cxled->cxld.dev));
 }
 
 static int match_free_decoder(struct device *dev, void *data)

-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ