Skip to contentSkip to conversation

crypto: octeontx2 - Replace deprecated strcpy in cpt_ucode_load_fw

PATCH In review Thorsten Blum 2 participants 2 messages Nov 1, 2025 – Nov 6, 2025

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

PATCH 1/1 crypto: octeontx2 - Replace deprecated strcpy in cpt_ucode_load_fw

strcpy() is deprecated; use the safer strscpy() instead.

The destination buffer is only zero-initialized for the first iteration and since strscpy() guarantees its NUL termination anyway, remove zero-initializing 'eng_type'.

---
 drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c +3 -2
index ebdf4efa09d4..b5cc5401f704 100644
@@ -3,6 +3,7 @@
 
 #include <linux/ctype.h>
 #include <linux/firmware.h>
+#include <linux/string.h>
 #include <linux/string_choices.h>
 #include "otx2_cptpf_ucode.h"
 #include "otx2_cpt_common.h"
@@ -458,13 +459,13 @@ static int cpt_ucode_load_fw(struct pci_dev *pdev, struct fw_info_t *fw_info,
 			     u16 rid)
 {
 	char filename[OTX2_CPT_NAME_LENGTH];
-	char eng_type[8] = {0};
+	char eng_type[8];
 	int ret, e, i;
 
 	INIT_LIST_HEAD(&fw_info->ucodes);
 
 	for (e = 1; e < OTX2_CPT_MAX_ENG_TYPES; e++) {
-		strcpy(eng_type, get_eng_type_str(e));
+		strscpy(eng_type, get_eng_type_str(e));
 		for (i = 0; i < strlen(eng_type); i++)
 			eng_type[i] = tolower(eng_type[i]);
 
Signature · 1 line
2.51.1
maintainer
#1 lore raw
Quoted 11 lines · Thorsten Blum

strcpy() is deprecated; use the safer strscpy() instead.

The destination buffer is only zero-initialized for the first iteration and since strscpy() guarantees its NUL termination anyway, remove zero-initializing 'eng_type'.

---
 drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c | 5 +++--
 1 file changed, 3 insertions(+), 2 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