Re: [PATCH 7/8] MIPS: octeon: Replace deprecated strcpy() in octeon_model_get_string_buffer()

From: Thomas Bogendoerfer
Date: Fri Aug 29 2025 - 06:33:47 EST


On Sun, Aug 17, 2025 at 08:37:17PM +0200, Thorsten Blum wrote:
> strcpy() is deprecated; use strscpy() instead.
>
> Link: https://github.com/KSPP/linux/issues/88
> Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxx>
> ---
> .../cavium-octeon/executive/octeon-model.c | 31 ++++++++++---------
> 1 file changed, 16 insertions(+), 15 deletions(-)
>
> diff --git a/arch/mips/cavium-octeon/executive/octeon-model.c b/arch/mips/cavium-octeon/executive/octeon-model.c
> index 657dbad9644e..98996cc0857e 100644
> --- a/arch/mips/cavium-octeon/executive/octeon-model.c
> +++ b/arch/mips/cavium-octeon/executive/octeon-model.c
> @@ -25,6 +25,7 @@
> * Contact Cavium Networks for more information
> ***********************license end**************************************/
>
> +#include <linux/string.h>
> #include <asm/octeon/octeon.h>
>
> enum octeon_feature_bits __octeon_feature_bits __read_mostly;
> @@ -208,16 +209,16 @@ static const char *__init octeon_model_get_string_buffer(uint32_t chip_id,
> */
> switch (chip_id & 0xf) {
> case 0:
> - strcpy(pass, "1.X");
> + strscpy(pass, "1.X");
> break;
> case 1:
> - strcpy(pass, "2.X");
> + strscpy(pass, "2.X");
> break;
> case 3:
> - strcpy(pass, "3.X");
> + strscpy(pass, "3.X");
> break;
> default:
> - strcpy(pass, "X.X");
> + strscpy(pass, "X.X");
> break;
> }
> break;
> @@ -232,13 +233,13 @@ static const char *__init octeon_model_get_string_buffer(uint32_t chip_id,
> */
> switch (chip_id & 0xf) {
> case 0:
> - strcpy(pass, "1.0");
> + strscpy(pass, "1.0");
> break;
> case 2:
> - strcpy(pass, "1.1");
> + strscpy(pass, "1.1");
> break;
> default:
> - strcpy(pass, "X.X");
> + strscpy(pass, "X.X");
> break;
> }
> break;
> @@ -253,13 +254,13 @@ static const char *__init octeon_model_get_string_buffer(uint32_t chip_id,
> */
> switch (chip_id & 0xf) {
> case 0:
> - strcpy(pass, "1.0");
> + strscpy(pass, "1.0");
> break;
> case 2:
> - strcpy(pass, "1.1");
> + strscpy(pass, "1.1");
> break;
> default:
> - strcpy(pass, "X.X");
> + strscpy(pass, "X.X");
> break;
> }
> break;
> @@ -273,16 +274,16 @@ static const char *__init octeon_model_get_string_buffer(uint32_t chip_id,
> if ((chip_id & 0xFF) < 0x8) {
> switch (chip_id & 0x3) {
> case 0:
> - strcpy(pass, "1.0");
> + strscpy(pass, "1.0");
> break;
> case 1:
> - strcpy(pass, "1.1");
> + strscpy(pass, "1.1");
> break;
> case 3:
> - strcpy(pass, "1.2");
> + strscpy(pass, "1.2");
> break;
> default:
> - strcpy(pass, "1.X");
> + strscpy(pass, "1.X");
> break;
> }
> }
> @@ -447,7 +448,7 @@ static const char *__init octeon_model_get_string_buffer(uint32_t chip_id,
> default:
> family = "XX";
> core_model = "XX";
> - strcpy(pass, "X.X");
> + strscpy(pass, "X.X");
> suffix = "XXX";
> break;
> }
> --
> 2.50.1

applied to mips-next.

Thomas.

--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]