Skip to content

Commit 99c31bf

Browse files
vlsunilrafaeljw
authored andcommitted
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>
1 parent 2ccdd1b commit 99c31bf

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/pnp/pnpacpi/core.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
254254
else
255255
strncpy(dev->name, acpi_device_bid(device), sizeof(dev->name));
256256

257+
/* Handle possible string truncation */
258+
dev->name[sizeof(dev->name) - 1] = '\0';
259+
257260
if (dev->active)
258261
pnpacpi_parse_allocated_resource(dev);
259262

0 commit comments

Comments
 (0)