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: <20240222180033.23775-8-quic_mojha@quicinc.com>
Date: Thu, 22 Feb 2024 23:30:32 +0530
From: Mukesh Ojha <quic_mojha@...cinc.com>
To: <mcgrof@...nel.org>, <russ.weight@...ux.dev>, <gregkh@...uxfoundation.org>,
        <rafael@...nel.org>
CC: <linux-kernel@...r.kernel.org>, Mukesh Ojha <quic_mojha@...cinc.com>
Subject: [PATCH vRFC 7/8] firmware: remove prototype of fw_cache_piggyback_on_request()

We should always try to avoid using prototype of a static
function like fw_cache_piggyback_on_request() firmware
main file. Move the relevant code in such a way that avoid
the prototype usage.

Signed-off-by: Mukesh Ojha <quic_mojha@...cinc.com>
---
 drivers/base/firmware_loader/main.c | 109 ++++++++++++++--------------
 1 file changed, 54 insertions(+), 55 deletions(-)

diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c
index 1d752965d311..91a45767a3a7 100644
--- a/drivers/base/firmware_loader/main.c
+++ b/drivers/base/firmware_loader/main.c
@@ -100,8 +100,6 @@ static inline int fw_state_wait(struct fw_priv *fw_priv)
 	return __fw_state_wait_common(fw_priv, MAX_SCHEDULE_TIMEOUT);
 }
 
-static void fw_cache_piggyback_on_request(struct fw_priv *fw_priv);
-
 static struct fw_priv *__allocate_fw_priv(const char *fw_name,
 					  struct firmware_cache *fwc,
 					  void *dbuf,
@@ -672,7 +670,61 @@ static int fw_add_devm_name(struct device *dev, const char *name)
 
 	return 0;
 }
+
+static struct fw_cache_entry *alloc_fw_cache_entry(const char *name)
+{
+	struct fw_cache_entry *fce;
+
+	fce = kzalloc(sizeof(*fce), GFP_ATOMIC);
+	if (!fce)
+		goto exit;
+
+	fce->name = kstrdup_const(name, GFP_ATOMIC);
+	if (!fce->name) {
+		kfree(fce);
+		fce = NULL;
+		goto exit;
+	}
+exit:
+	return fce;
+}
+
+static int __fw_entry_found(const char *name)
+{
+	struct firmware_cache *fwc = &fw_cache;
+	struct fw_cache_entry *fce;
+
+	list_for_each_entry(fce, &fwc->fw_names, list) {
+		if (!strcmp(fce->name, name))
+			return 1;
+	}
+	return 0;
+}
+
+static void fw_cache_piggyback_on_request(struct fw_priv *fw_priv)
+{
+	const char *name = fw_priv->fw_name;
+	struct firmware_cache *fwc = fw_priv->fwc;
+	struct fw_cache_entry *fce;
+
+	spin_lock(&fwc->name_lock);
+	if (__fw_entry_found(name))
+		goto found;
+
+	fce = alloc_fw_cache_entry(name);
+	if (fce) {
+		list_add(&fce->list, &fwc->fw_names);
+		kref_get(&fw_priv->ref);
+		pr_debug("%s: fw: %s\n", __func__, name);
+	}
+found:
+	spin_unlock(&fwc->name_lock);
+}
+
 #else
+static void fw_cache_piggyback_on_request(struct fw_priv *fw_priv)
+{
+}
 static bool fw_cache_is_setup(struct device *dev, const char *name)
 {
 	return false;
@@ -1285,56 +1337,6 @@ static int uncache_firmware(const char *fw_name)
 	return -EINVAL;
 }
 
-static struct fw_cache_entry *alloc_fw_cache_entry(const char *name)
-{
-	struct fw_cache_entry *fce;
-
-	fce = kzalloc(sizeof(*fce), GFP_ATOMIC);
-	if (!fce)
-		goto exit;
-
-	fce->name = kstrdup_const(name, GFP_ATOMIC);
-	if (!fce->name) {
-		kfree(fce);
-		fce = NULL;
-		goto exit;
-	}
-exit:
-	return fce;
-}
-
-static int __fw_entry_found(const char *name)
-{
-	struct firmware_cache *fwc = &fw_cache;
-	struct fw_cache_entry *fce;
-
-	list_for_each_entry(fce, &fwc->fw_names, list) {
-		if (!strcmp(fce->name, name))
-			return 1;
-	}
-	return 0;
-}
-
-static void fw_cache_piggyback_on_request(struct fw_priv *fw_priv)
-{
-	const char *name = fw_priv->fw_name;
-	struct firmware_cache *fwc = fw_priv->fwc;
-	struct fw_cache_entry *fce;
-
-	spin_lock(&fwc->name_lock);
-	if (__fw_entry_found(name))
-		goto found;
-
-	fce = alloc_fw_cache_entry(name);
-	if (fce) {
-		list_add(&fce->list, &fwc->fw_names);
-		kref_get(&fw_priv->ref);
-		pr_debug("%s: fw: %s\n", __func__, name);
-	}
-found:
-	spin_unlock(&fwc->name_lock);
-}
-
 static void free_fw_cache_entry(struct fw_cache_entry *fce)
 {
 	kfree_const(fce->name);
@@ -1563,9 +1565,6 @@ static inline void unregister_fw_pm_ops(void)
 	unregister_pm_notifier(&fw_cache.pm_notify);
 }
 #else
-static void fw_cache_piggyback_on_request(struct fw_priv *fw_priv)
-{
-}
 static inline int register_fw_pm_ops(void)
 {
 	return 0;
-- 
2.43.0.254.ga26002b62827


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ