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-next>] [day] [month] [year] [list]
Date:   Mon, 20 Nov 2017 22:25:44 +0100
From:   SF Markus Elfring <elfring@...rs.sourceforge.net>
To:     linux-kselftest@...r.kernel.org,
        Emilio López <emilio.lopez@...labora.co.uk>,
        Shuah Khan <shuah@...nel.org>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        kernel-janitors@...r.kernel.org
Subject: [PATCH] selftest: sync: Use common error handling code in
 sync_file_info()

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Mon, 20 Nov 2017 22:20:37 +0100

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

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
 tools/testing/selftests/sync/sync.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/tools/testing/selftests/sync/sync.c b/tools/testing/selftests/sync/sync.c
index f3d599f249b9..d0d55377f6f8 100644
--- a/tools/testing/selftests/sync/sync.c
+++ b/tools/testing/selftests/sync/sync.c
@@ -92,10 +92,8 @@ static struct sync_file_info *sync_file_info(int fd)
 		return NULL;
 
 	err = ioctl(fd, SYNC_IOC_FILE_INFO, info);
-	if (err < 0) {
-		free(info);
-		return NULL;
-	}
+	if (err < 0)
+		goto free_info;
 
 	num_fences = info->num_fences;
 
@@ -104,22 +102,23 @@ static struct sync_file_info *sync_file_info(int fd)
 		info->num_fences = num_fences;
 
 		fence_info = calloc(num_fences, sizeof(*fence_info));
-		if (!fence_info) {
-			free(info);
-			return NULL;
-		}
+		if (!fence_info)
+			goto free_info;
 
 		info->sync_fence_info = (uint64_t)fence_info;
 
 		err = ioctl(fd, SYNC_IOC_FILE_INFO, info);
 		if (err < 0) {
 			free(fence_info);
-			free(info);
-			return NULL;
+			goto free_info;
 		}
 	}
 
 	return info;
+
+free_info:
+	free(info);
+	return NULL;
 }
 
 static void sync_file_info_free(struct sync_file_info *info)
-- 
2.15.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ