eeprom: at25: Replace strncpy() with strscpy()

Use strscpy() instead of strncpy(), since its use has been deprecated[1].

[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Jiri Prchal <jiri.prchal@aksignal.cz>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20220118182047.3385295-1-keescook@chromium.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Kees Cook 2022-01-18 10:20:47 -08:00 committed by Greg Kroah-Hartman
parent 71732e2460
commit 710f8af199
1 changed files with 2 additions and 2 deletions

View File

@ -309,7 +309,7 @@ static int at25_fw_to_chip(struct device *dev, struct spi_eeprom *chip)
u32 val; u32 val;
int err; int err;
strncpy(chip->name, "at25", sizeof(chip->name)); strscpy(chip->name, "at25", sizeof(chip->name));
err = device_property_read_u32(dev, "size", &val); err = device_property_read_u32(dev, "size", &val);
if (err) if (err)
@ -370,7 +370,7 @@ static int at25_fram_to_chip(struct device *dev, struct spi_eeprom *chip)
u8 id[FM25_ID_LEN]; u8 id[FM25_ID_LEN];
int i; int i;
strncpy(chip->name, "fm25", sizeof(chip->name)); strscpy(chip->name, "fm25", sizeof(chip->name));
/* Get ID of chip */ /* Get ID of chip */
fm25_aux_read(at25, id, FM25_RDID, FM25_ID_LEN); fm25_aux_read(at25, id, FM25_RDID, FM25_ID_LEN);