diff options
| author | Thorsten Blum <thorsten.blum@linux.dev> | 2025-10-13 16:57:02 +0300 |
|---|---|---|
| committer | Madhavan Srinivasan <maddy@linux.ibm.com> | 2026-06-02 08:54:33 +0300 |
| commit | c8f80f95da32618d49c2a068ee561b85655b761d (patch) | |
| tree | 7749a709a7f2e744c066df23e858b6bb2852e3f0 | |
| parent | 457cf3d00dab71b7e74603b6ee96e13c51a8fd3d (diff) | |
| download | linux-c8f80f95da32618d49c2a068ee561b85655b761d.tar.xz | |
powerpc/pseries/lparcfg: Replace deprecated strcpy in parse_system_parameter_string
strcpy() is deprecated; use strscpy() instead. Use the return value of
strscpy() instead of calling strlen() again, and ignore any potential
string truncation since both strings are much shorter than the buffer
size SPLPAR_MAXLENGTH.
Change both if conditions to silence the following checkpatch warnings:
Comparisons should place the constant on the right side of the test
Link: https://github.com/KSPP/linux/issues/88
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20251013135703.97260-2-thorsten.blum@linux.dev
| -rw-r--r-- | arch/powerpc/platforms/pseries/lparcfg.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/arch/powerpc/platforms/pseries/lparcfg.c b/arch/powerpc/platforms/pseries/lparcfg.c index 8821c378bfff..54b7ecf375b5 100644 --- a/arch/powerpc/platforms/pseries/lparcfg.c +++ b/arch/powerpc/platforms/pseries/lparcfg.c @@ -22,6 +22,7 @@ #include <asm/papr-sysparm.h> #include <linux/seq_file.h> #include <linux/slab.h> +#include <linux/string.h> #include <linux/uaccess.h> #include <linux/hugetlb.h> #include <asm/lppaca.h> @@ -431,17 +432,18 @@ static void parse_system_parameter_string(struct seq_file *m) w_idx = 0; } else if (local_buffer[idx] == '=') { /* code here to replace workbuffer contents - with different keyword strings */ - if (0 == strcmp(workbuffer, "MaxEntCap")) { - strcpy(workbuffer, - "partition_max_entitled_capacity"); - w_idx = strlen(workbuffer); - } - if (0 == strcmp(workbuffer, "MaxPlatProcs")) { - strcpy(workbuffer, - "system_potential_processors"); - w_idx = strlen(workbuffer); - } + * with different keyword strings. Truncation + * by strscpy is deliberately ignored because + * SPLPAR_MAXLENGTH >= maximum string size. + */ + if (!strcmp(workbuffer, "MaxEntCap")) + w_idx = strscpy(workbuffer, + "partition_max_entitled_capacity", + SPLPAR_MAXLENGTH); + if (!strcmp(workbuffer, "MaxPlatProcs")) + w_idx = strscpy(workbuffer, + "system_potential_processors", + SPLPAR_MAXLENGTH); } } kfree(workbuffer); |
