* [PATCH] PNP/ACPI: Fix string truncation warning
@ 2023-07-25 5:29 Sunil V L
2023-08-17 17:39 ` Rafael J. Wysocki
0 siblings, 1 reply; 2+ messages in thread
From: Sunil V L @ 2023-07-25 5:29 UTC (permalink / raw)
To: linux-acpi, linux-kernel
Cc: Rafael J . Wysocki, Len Brown, Palmer Dabbelt, Andrew Jones,
Conor Dooley, Sunil V L, kernel test robot
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 <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>
---
drivers/pnp/pnpacpi/core.c | 3 +++
1 file changed, 3 insertions(+)
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);
--
2.39.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] PNP/ACPI: Fix string truncation warning
2023-07-25 5:29 [PATCH] PNP/ACPI: Fix string truncation warning Sunil V L
@ 2023-08-17 17:39 ` Rafael J. Wysocki
0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2023-08-17 17:39 UTC (permalink / raw)
To: Sunil V L
Cc: linux-acpi, linux-kernel, Rafael J . Wysocki, Len Brown,
Palmer Dabbelt, Andrew Jones, Conor Dooley, kernel test robot
On Tue, Jul 25, 2023 at 7:29 AM Sunil V L <sunilvl@ventanamicro.com> wrote:
>
> 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 <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>
> ---
> drivers/pnp/pnpacpi/core.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> 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);
>
> --
Applied as 6.6 material, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-08-17 17:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-25 5:29 [PATCH] PNP/ACPI: Fix string truncation warning Sunil V L
2023-08-17 17:39 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®