summaryrefslogtreecommitdiffstats
path: root/drivers/pnp
diff options
context:
space:
mode:
authorSunil V L <sunilvl@ventanamicro.com>2023-07-25 10:59:25 +0530
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2023-08-17 19:38:35 +0200
commit99c31bff185610304532c4acf00cda341572e2d4 (patch)
tree82d6b5d3085c4e34cf9571e0b844de7523f9fbd7 /drivers/pnp
parent2ccdd1b13c591d306f0401d98dedc4bdcd02b421 (diff)
downloadlinux-99c31bff185610304532c4acf00cda341572e2d4.tar.gz
linux-99c31bff185610304532c4acf00cda341572e2d4.tar.bz2
linux-99c31bff185610304532c4acf00cda341572e2d4.zip
PNP: ACPI: Fix string truncation warning
LKP reports below warning when building for RISC-V. drivers/pnp/pnpacpi/core.c:253:17: warning: 'strncpy' specified bound 50 equals destination size [-Wstringop-truncation] This appears to be a valid issue since the destination string may not be null-terminated. To fix this, append the NUL explicitly after the strncpy(). Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202307241942.Rff2Nri5-lkp@intel.com/ Signed-off-by: Sunil V L <sunilvl@ventanamicro.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/pnp')
-rw-r--r--drivers/pnp/pnpacpi/core.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index 38928ff7472b..6ab272c84b7b 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -254,6 +254,9 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
else
strncpy(dev->name, acpi_device_bid(device), sizeof(dev->name));
+ /* Handle possible string truncation */
+ dev->name[sizeof(dev->name) - 1] = '\0';
+
if (dev->active)
pnpacpi_parse_allocated_resource(dev);