From b7d436fd0eeb6f77ecb1f71a44647051a0076a84 Mon Sep 17 00:00:00 2001 From: Sagar Kamble Date: Tue, 10 May 2022 15:54:23 +0530 Subject: [PATCH] gpu: nvgpu: consider null character for strncat While forming string available length to strncat should consider null character in last byte otherwise strncat can index the array out of bounds. CID 481139 CID 455841 Bug 3512546 Change-Id: I011be1deea40e276e681965deefb60fe8ab79479 Signed-off-by: Sagar Kamble Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2710380 Reviewed-by: svcacv Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-cert Reviewed-by: Sachin Nikam GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/os/linux/linux-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/nvgpu/os/linux/linux-dma.c b/drivers/gpu/nvgpu/os/linux/linux-dma.c index 482b751a4..b97e7af41 100644 --- a/drivers/gpu/nvgpu/os/linux/linux-dma.c +++ b/drivers/gpu/nvgpu/os/linux/linux-dma.c @@ -48,7 +48,7 @@ */ void nvgpu_dma_flags_to_str(struct gk20a *g, unsigned long flags, char *buf) { - int bytes_available = NVGPU_DMA_STR_SIZE; + int bytes_available = NVGPU_DMA_STR_SIZE - 1; memset(buf, 0, NVGPU_DMA_STR_SIZE);