Skip to contentSkip to conversation

crypto: iaa - Replace sprintf with sysfs_emit in sysfs show functions

PATCH In review Thorsten Blum 3 participants 3 messages Dec 15, 2025 – Dec 29, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: iaa - Replace sprintf with sysfs_emit in sysfs show functions

Replace sprintf() with sysfs_emit() in verify_compress_show() and sync_mode_show(). sysfs_emit() is preferred to format sysfs output as it provides better bounds checking. No functional changes.

---
 drivers/crypto/intel/iaa/iaa_crypto_main.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/crypto/intel/iaa/iaa_crypto_main.c +5 -4
index d0058757b000..9e2a17c473ef 100644
@@ -5,6 +5,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/sysfs.h>
 #include <linux/device.h>
 #include <linux/iommu.h>
 #include <uapi/linux/idxd.h>
@@ -96,7 +97,7 @@ static bool iaa_verify_compress = true;
 
 static ssize_t verify_compress_show(struct device_driver *driver, char *buf)
 {
-	return sprintf(buf, "%d\n", iaa_verify_compress);
+	return sysfs_emit(buf, "%d\n", iaa_verify_compress);
 }
 
 static ssize_t verify_compress_store(struct device_driver *driver,
@@ -188,11 +189,11 @@ static ssize_t sync_mode_show(struct device_driver *driver, char *buf)
 	int ret = 0;
 
 	if (!async_mode && !use_irq)
-		ret = sprintf(buf, "%s\n", "sync");
+		ret = sysfs_emit(buf, "%s\n", "sync");
 	else if (async_mode && !use_irq)
-		ret = sprintf(buf, "%s\n", "async");
+		ret = sysfs_emit(buf, "%s\n", "async");
 	else if (async_mode && use_irq)
-		ret = sprintf(buf, "%s\n", "async_irq");
+		ret = sysfs_emit(buf, "%s\n", "async_irq");
 
 	return ret;
 }
Signature · 2 lines
Thorsten Blum <[email protected]>
GPG: 1D60 735E 8AEF 3BE4 73B6  9D84 7336 78FD 8DFE EAD4
Acked-by on v1 1/1
#1 lore raw
Quoted 13 lines

-----Original Message-----
From: Thorsten Blum <[email protected]>
Sent: Sunday, December 14, 2025 11:24 PM
To: Accardi, Kristen C <[email protected]>; Gomes, Vinicius <[email protected]>; Sridhar, Kanchana P <[email protected]>; Herbert Xu <[email protected]>; David S. Miller <[email protected]>
Cc: Thorsten Blum <[email protected]>; [email protected]; [email protected]
Subject: [PATCH] crypto: iaa - Replace sprintf with sysfs_emit in sysfs show functions

Quoted 5 lines

Replace sprintf() with sysfs_emit() in verify_compress_show() and sync_mode_show(). sysfs_emit() is preferred to format sysfs output as it provides better bounds checking. No functional changes.

Quoted 45 lines
---
 drivers/crypto/intel/iaa/iaa_crypto_main.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/crypto/intel/iaa/iaa_crypto_main.c +5 -4
index d0058757b000..9e2a17c473ef 100644
@@ -5,6 +5,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/sysfs.h>
 #include <linux/device.h>
 #include <linux/iommu.h>
 #include <uapi/linux/idxd.h>
@@ -96,7 +97,7 @@ static bool iaa_verify_compress = true;
 
 static ssize_t verify_compress_show(struct device_driver *driver, char *buf)
 {
-	return sprintf(buf, "%d\n", iaa_verify_compress);
+	return sysfs_emit(buf, "%d\n", iaa_verify_compress);
 }
 
 static ssize_t verify_compress_store(struct device_driver *driver,
@@ -188,11 +189,11 @@ static ssize_t sync_mode_show(struct
 device_driver *driver, char *buf)
 	int ret = 0;
 
 	if (!async_mode && !use_irq)
-		ret = sprintf(buf, "%s\n", "sync");
+		ret = sysfs_emit(buf, "%s\n", "sync");
 	else if (async_mode && !use_irq)
-		ret = sprintf(buf, "%s\n", "async");
+		ret = sysfs_emit(buf, "%s\n", "async");
 	else if (async_mode && use_irq)
-		ret = sprintf(buf, "%s\n", "async_irq");
+		ret = sysfs_emit(buf, "%s\n", "async_irq");
 
 	return ret;

}
--
Thorsten Blum <[email protected]>
GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4

maintainer
#2 lore raw
In reply to Thorsten Blum
Quoted 8 lines · Thorsten Blum

Replace sprintf() with sysfs_emit() in verify_compress_show() and sync_mode_show(). sysfs_emit() is preferred to format sysfs output as it provides better bounds checking. No functional changes.

---
 drivers/crypto/intel/iaa/iaa_crypto_main.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt