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: <20191105145602.GH10409@kadam>
Date:   Tue, 5 Nov 2019 17:56:02 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     Mao Wenan <maowenan@...wei.com>
Cc:     wangzhou1@...ilicon.com, herbert@...dor.apana.org.au,
        davem@...emloft.net, tanshukun1@...wei.com,
        linux-crypto@...r.kernel.org, linux-kernel@...r.kernel.org,
        kernel-janitors@...r.kernel.org
Subject: Re: [PATCH -next] crypto: hisilicon: move label err to #ifdef
 CONFIG_NUMA

The ifdefs in this function were pretty ugly before but this makes it
super extra ugly...  :/  There are bunch of ways to fix this nicely
but my favourite is this:

Feel free to give me a Suggested-by tag.

diff --git a/drivers/crypto/hisilicon/zip/zip_main.c b/drivers/crypto/hisilicon/zip/zip_main.c
index 255b63cfbe1d..1b22f0ead56e 100644
--- a/drivers/crypto/hisilicon/zip/zip_main.c
+++ b/drivers/crypto/hisilicon/zip/zip_main.c
@@ -105,20 +105,27 @@ static void free_list(struct list_head *head)
 struct hisi_zip *find_zip_device(int node)
 {
 	struct hisi_zip *ret = NULL;
-#ifdef CONFIG_NUMA
 	struct hisi_zip_resource *res, *tmp;
 	struct hisi_zip *hisi_zip;
 	struct list_head *n;
 	struct device *dev;
 	LIST_HEAD(head);
 
+	if (!IS_ENABLED(CONFIG_NUMA)) {
+		mutex_lock(&hisi_zip_list_lock);
+		ret = list_first_entry(&hisi_zip_list, struct hisi_zip, list);
+		mutex_unlock(&hisi_zip_list_lock);
+		return ret;
+	}
+
 	mutex_lock(&hisi_zip_list_lock);
 
 	list_for_each_entry(hisi_zip, &hisi_zip_list, list) {
 		res = kzalloc(sizeof(*res), GFP_KERNEL);
-		if (!res)
-			goto err;
-
+		if (!res) {
+			ret = NULL;
+			goto done;
+		}
 		dev = &hisi_zip->qm.pdev->dev;
 		res->hzip = hisi_zip;
 		res->distance = node_distance(dev->numa_node, node);
@@ -140,20 +147,10 @@ struct hisi_zip *find_zip_device(int node)
 		}
 	}
 
+done:
 	free_list(&head);
-#else
-	mutex_lock(&hisi_zip_list_lock);
-
-	ret = list_first_entry(&hisi_zip_list, struct hisi_zip, list);
-#endif
 	mutex_unlock(&hisi_zip_list_lock);
-
 	return ret;
-
-err:
-	free_list(&head);
-	mutex_unlock(&hisi_zip_list_lock);
-	return NULL;
 }
 
 struct hisi_zip_hw_error {

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ