summaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorMinghao Chi <chi.minghao@zte.com.cn>2022-09-19 02:49:19 +0000
committerSebastian Reichel <sre@kernel.org>2023-02-03 13:58:41 +0100
commit301cfbc1249759415ff864bdf46e15c7e103279b (patch)
tree25e866582a9bb6c0a4982511a1caaad88249464f /drivers/power
parent3639dbd74e2e827d544bdb28b663a44449c014e1 (diff)
power: supply: max1721x: Use strscpy() is more robust and safer
The implementation of strscpy() is more robust and safer. That's now the recommended way to copy NUL terminated strings. Reported-by: Zeal Robot <zealci@zte.com.cn> Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/supply/max1721x_battery.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/power/supply/max1721x_battery.c b/drivers/power/supply/max1721x_battery.c
index d8d52e09da7b..bac43ab9e97c 100644
--- a/drivers/power/supply/max1721x_battery.c
+++ b/drivers/power/supply/max1721x_battery.c
@@ -384,7 +384,7 @@ static int devm_w1_max1721x_add_device(struct w1_slave *sl)
}
if (!info->ManufacturerName[0])
- strncpy(info->ManufacturerName, DEF_MFG_NAME,
+ strscpy(info->ManufacturerName, DEF_MFG_NAME,
2 * MAX1721X_REG_MFG_NUMB);
if (get_string(info, MAX1721X_REG_DEV_STR,
@@ -403,15 +403,15 @@ static int devm_w1_max1721x_add_device(struct w1_slave *sl)
switch (dev_name & MAX172XX_DEV_MASK) {
case MAX172X1_DEV:
- strncpy(info->DeviceName, DEF_DEV_NAME_MAX17211,
+ strscpy(info->DeviceName, DEF_DEV_NAME_MAX17211,
2 * MAX1721X_REG_DEV_NUMB);
break;
case MAX172X5_DEV:
- strncpy(info->DeviceName, DEF_DEV_NAME_MAX17215,
+ strscpy(info->DeviceName, DEF_DEV_NAME_MAX17215,
2 * MAX1721X_REG_DEV_NUMB);
break;
default:
- strncpy(info->DeviceName, DEF_DEV_NAME_UNKNOWN,
+ strscpy(info->DeviceName, DEF_DEV_NAME_UNKNOWN,
2 * MAX1721X_REG_DEV_NUMB);
}
}