mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 10:34:43 +03:00
gpu: nvgpu: utils: fix CERT-C violations
Rule INT31-C requires that integer conversions do not result in lost or misinterpreted data. Rule INT32-C requires that operations on signed integers do not result in overflow. Rule EXP34-C requires that pointer dereferences never include NULL. Fix violations of these types in nvgpu.common.utils. JIRA NVGPU-3868 Change-Id: Ifcf4bc6536ca2df2adcb53b40b3e58316cc3e457 Signed-off-by: Philip Elcan <pelcan@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2168576 Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Vinod Gopalakrishnakurup <vinodg@nvidia.com> Reviewed-by: Nitin Kumbhar <nkumbhar@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
390695e67e
commit
09f7dd7fdd
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <nvgpu/string.h>
|
||||
#include <nvgpu/log.h>
|
||||
#include <nvgpu/safe_ops.h>
|
||||
|
||||
void
|
||||
nvgpu_memcpy(u8 *destb, const u8 *srcb, size_t n)
|
||||
@@ -50,12 +51,12 @@ int nvgpu_strnadd_u32(char *dst, const u32 value, size_t size, u32 radix)
|
||||
n = 0;
|
||||
v = value;
|
||||
do {
|
||||
n++;
|
||||
n = nvgpu_safe_add_s32(n, 1);
|
||||
v = v / radix;
|
||||
} while (v > 0U);
|
||||
|
||||
/* bail out if there is not room for '\0' */
|
||||
if (n >= (int)size) {
|
||||
if (n >= nvgpu_safe_cast_u64_to_s32(size)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user