tegra: nvmap: Fix overflow defects in nvmap_dev.c

Fix subtraction and addition overflow defects in nvmap_dev.c using
overflow.h APIs. Add fix for 1 INT 08-C and 1 INT 30-C defect.

Bug 4479044

Change-Id: I5dbd4d66b661c61967847c155f4e03fd9140087c
Signed-off-by: N V S Abhishek <nabhishek@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3262873
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Reviewed-by: Ketan Patil <ketanp@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
N V S Abhishek
2024-12-05 19:55:24 +00:00
committed by Jon Hunter
parent df3b6e37ff
commit 329cbf5ff0

View File

@@ -561,6 +561,7 @@ int __init nvmap_probe(struct platform_device *pdev)
int e;
int generic_carveout_present = 0;
ulong start_time = sched_clock();
ulong result;
if (WARN_ON(nvmap_dev != NULL)) {
dev_err(&pdev->dev, "only one nvmap device may be present\n");
@@ -676,7 +677,13 @@ fail:
misc_deregister(&dev->dev_user);
nvmap_dev = NULL;
finish:
nvmap_init_time += sched_clock() - start_time;
if (check_sub_overflow((ulong)sched_clock(),
start_time, &result) ||
check_add_overflow(nvmap_init_time,
result, &result))
return -EOVERFLOW;
nvmap_init_time = result;
return e;
}