diff options
author | dmitry pervushin <dpervushin@nvidia.com> | 2020-05-11 13:31:25 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2020-05-13 15:40:51 -0400 |
commit | aa6d4d08d4c161aa91ba2ef4330e03b61a0ca3cb (patch) | |
tree | 4b3a8394440073e693607038362375ecfdae89da | |
parent | 9d1e07ca184869eb0082b418d0d1cf6e62af3a40 (diff) |
strncpy: it should depend on size of 1st argument
There is no point to depend on strlen of second argument,
otherwise it could be a simple strcpy. Instead, let's make
it depending on sizeof(destination)
...and make sure that result is NUL-terminated, too
Bug 2973859
Change-Id: Ifc941fab07e503b7b980696950d65b8bb10bf4ff
Signed-off-by: dmitry pervushin <dpervushin@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2342281
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Phoenix Jung <pjung@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/vm.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/gpu/nvgpu/common/mm/vm.c b/drivers/gpu/nvgpu/common/mm/vm.c index 4a7cc828..e6ca38c8 100644 --- a/drivers/gpu/nvgpu/common/mm/vm.c +++ b/drivers/gpu/nvgpu/common/mm/vm.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2017-2019, NVIDIA CORPORATION. All rights reserved. | 2 | * Copyright (c) 2017-2020, NVIDIA CORPORATION. All rights reserved. |
3 | * | 3 | * |
4 | * Permission is hereby granted, free of charge, to any person obtaining a | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
5 | * copy of this software and associated documentation files (the "Software"), | 5 | * copy of this software and associated documentation files (the "Software"), |
@@ -339,7 +339,8 @@ int __nvgpu_vm_init(struct mm_gk20a *mm, | |||
339 | #endif | 339 | #endif |
340 | 340 | ||
341 | /* Initialize the page table data structures. */ | 341 | /* Initialize the page table data structures. */ |
342 | strncpy(vm->name, name, min(strlen(name), sizeof(vm->name))); | 342 | strncpy(vm->name, name, sizeof(vm->name)); |
343 | vm->name[sizeof(vm->name) - 1] = '\0'; | ||
343 | err = nvgpu_gmmu_init_page_table(vm); | 344 | err = nvgpu_gmmu_init_page_table(vm); |
344 | if (err) { | 345 | if (err) { |
345 | goto clean_up_vgpu_vm; | 346 | goto clean_up_vgpu_vm; |