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: <20240812235210.28458-2-o-takashi@sakamocchi.jp>
Date: Tue, 13 Aug 2024 08:52:06 +0900
From: Takashi Sakamoto <o-takashi@...amocchi.jp>
To: linux1394-devel@...ts.sourceforge.net
Cc: linux-kernel@...r.kernel.org
Subject: [PATCH 1/5] firewire: core: minor code refactoring to release client resource

Current implementation checks and validates the result to find resource
entry two times. It is redundant.

This commit refactors the redundancy.

Signed-off-by: Takashi Sakamoto <o-takashi@...amocchi.jp>
---
 drivers/firewire/core-cdev.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
index c211bb19c94e..81fdb2be9063 100644
--- a/drivers/firewire/core-cdev.c
+++ b/drivers/firewire/core-cdev.c
@@ -512,15 +512,14 @@ static int release_client_resource(struct client *client, u32 handle,
 
 	scoped_guard(spinlock_irq, &client->lock) {
 		if (client->in_shutdown)
-			resource = NULL;
-		else
-			resource = idr_find(&client->resource_idr, handle);
-		if (resource && resource->release == release)
-			idr_remove(&client->resource_idr, handle);
-	}
+			return -EINVAL;
 
-	if (!(resource && resource->release == release))
-		return -EINVAL;
+		resource = idr_find(&client->resource_idr, handle);
+		if (!resource || resource->release != release)
+			return -EINVAL;
+
+		idr_remove(&client->resource_idr, handle);
+	}
 
 	if (return_resource)
 		*return_resource = resource;
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ