diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c b/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c
index 45d34aa20..a9a65886b 100644
--- a/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c
+++ b/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c
@@ -1,18 +1,5 @@
-/*
- * Copyright (c) 2011-2023, NVIDIA Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
+// SPDX-License-Identifier: GPL-2.0-only
+// SPDX-FileCopyrightText: Copyright (c) 2011-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#include
#include
@@ -386,6 +373,7 @@ static long gk20a_ctrl_ioctl_gpu_characteristics(
struct nvgpu_gpu_characteristics gpu;
long err = 0;
struct nvgpu_gpu_instance *gpu_instance;
+ ssize_t len;
u32 gr_instance_id = nvgpu_grmgr_get_gr_instance_id(g, gpu_instance_id);
@@ -516,7 +504,10 @@ static long gk20a_ctrl_ioctl_gpu_characteristics(
gpu.gpu_va_bit_count = 40;
gpu.max_dbg_tsg_timeslice = g->tsg_dbg_timeslice_max_us;
- strlcpy(gpu.chipname, g->name, sizeof(gpu.chipname));
+ len = strscpy(gpu.chipname, g->name, sizeof(gpu.chipname));
+ if (len < 0)
+ return -ENAMETOOLONG;
+
gpu.max_fbps_count = nvgpu_grmgr_get_max_fbps_count(g);
gpu.fbp_en_mask = nvgpu_grmgr_get_fbp_en_mask(g, gpu_instance_id);
gpu.max_ltc_per_fbp = g->ops.top.get_max_ltc_per_fbp(g);
diff --git a/drivers/gpu/nvgpu/os/linux/pci_power.c b/drivers/gpu/nvgpu/os/linux/pci_power.c
index b0edddc26..6406eb35a 100644
--- a/drivers/gpu/nvgpu/os/linux/pci_power.c
+++ b/drivers/gpu/nvgpu/os/linux/pci_power.c
@@ -1,18 +1,5 @@
-/*
- * Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
+// SPDX-License-Identifier: GPL-2.0-only
+// SPDX-FileCopyrightText: Copyright (c) 2018-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#include
#include
@@ -74,6 +61,7 @@ int nvgpu_pci_add_pci_power(struct pci_dev *pdev)
{
struct gk20a_platform *platform;
struct nvgpu_pci_power *pp;
+ ssize_t len;
if (!pdev)
return -EINVAL;
@@ -90,8 +78,10 @@ int nvgpu_pci_add_pci_power(struct pci_dev *pdev)
nvgpu_mutex_init(&pp->mutex);
pp->pci_dev = pdev;
- strlcpy(pp->pci_dev_name,
+ len = strscpy(pp->pci_dev_name,
dev_name(&pdev->dev), PCI_DEV_NAME_MAX);
+ if (len < 0)
+ return -ENAMETOOLONG;
platform = pci_get_drvdata(pdev);
pp->can_pci_gc_off = platform->can_pci_gc_off;