[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251022123622.349544-1-thorsten.blum@linux.dev>
Date: Wed, 22 Oct 2025 14:36:19 +0200
From: Thorsten Blum <thorsten.blum@...ux.dev>
To: Giovanni Cabiddu <giovanni.cabiddu@...el.com>,
Herbert Xu <herbert@...dor.apana.org.au>,
"David S. Miller" <davem@...emloft.net>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Jack Xu <jack.xu@...el.com>,
Suman Kumar Chakraborty <suman.kumar.chakraborty@...el.com>,
Qianfeng Rong <rongqianfeng@...o.com>
Cc: Thorsten Blum <thorsten.blum@...ux.dev>,
qat-linux@...el.com,
linux-crypto@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] crypto: qat - use strscpy_pad to simplify buffer initialization
Use strscpy_pad() to copy the string and zero-pad the destination buffer
in a single step instead of zero-initializing the buffer first and then
immediately overwriting it using strscpy().
Replace the magic number 16 with sizeof(buf) and remove the redundant
parentheses around kstrtoul() while we're at it.
Signed-off-by: Thorsten Blum <thorsten.blum@...ux.dev>
---
drivers/crypto/intel/qat/qat_common/qat_uclo.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/crypto/intel/qat/qat_common/qat_uclo.c b/drivers/crypto/intel/qat/qat_common/qat_uclo.c
index 18c3e4416dc5..41a7bd434e97 100644
--- a/drivers/crypto/intel/qat/qat_common/qat_uclo.c
+++ b/drivers/crypto/intel/qat/qat_common/qat_uclo.c
@@ -200,18 +200,18 @@ qat_uclo_cleanup_batch_init_list(struct icp_qat_fw_loader_handle *handle,
static int qat_uclo_parse_num(char *str, unsigned int *num)
{
- char buf[16] = {0};
+ char buf[16] = {};
unsigned long ae = 0;
int i;
- strscpy(buf, str, sizeof(buf));
- for (i = 0; i < 16; i++) {
+ strscpy_pad(buf, str);
+ for (i = 0; i < sizeof(buf); i++) {
if (!isdigit(buf[i])) {
buf[i] = '\0';
break;
}
}
- if ((kstrtoul(buf, 10, &ae)))
+ if (kstrtoul(buf, 10, &ae))
return -EFAULT;
*num = (unsigned int)ae;
--
2.51.0
Powered by blists - more mailing lists