PNP/ACPI: Fix string truncation warning
Subsystems (2)
PATCH 1/1 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 like a valid issue since the destination string may not be null-terminated. To fix this, append the NUL explicitly after the strncpy.
--- drivers/pnp/pnpacpi/core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/pnp/pnpacpi/core.c +3 -0
@@ -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);
Signature · 1 line
2.39.2
Quoted 23 lines · Sunil V L
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 like 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 <[email protected]>Signed-off-by Sunil V L <[email protected]>--- drivers/pnp/pnpacpi/core.c | 3 +++ 1 file changed, 3 insertions(+)drivers/pnp/pnpacpi/core.c +0
-0
drivers/pnp/pnpacpi/core.c static int __init pnpacpi_add_device(struct acpi_device *device)
Quoted 10 lines
drivers/pnp/pnpacpi/core.c +3
-1@@ -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); --
Applied as 6.6 material, thanks!