From c79fe58101fbef10e243567d95780197fb875df3 Mon Sep 17 00:00:00 2001 From: Surbhi Singh Date: Fri, 18 Oct 2024 03:55:15 +0000 Subject: [PATCH] video: tegra: nvmap: Fix INT08-C using overflow.h - pend-pstart may wrap, hence using check_sub_overflow. JIRA: TMM-5724 Bug 4479044 Change-Id: I0214a453919ab6d789811b3cb02525d3c78b7932 Signed-off-by: Surbhi Singh Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3232443 GVS: buildbot_gerritrpt Reviewed-by: svcacv Reviewed-by: Sachin Nikam --- drivers/video/tegra/nvmap/nvmap_cache.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/video/tegra/nvmap/nvmap_cache.c b/drivers/video/tegra/nvmap/nvmap_cache.c index 6b11727f..bc1cc7a0 100644 --- a/drivers/video/tegra/nvmap/nvmap_cache.c +++ b/drivers/video/tegra/nvmap/nvmap_cache.c @@ -164,6 +164,7 @@ static int do_cache_maint(struct cache_maint_op *cache_work) int err = 0; struct nvmap_handle *h = cache_work->h; unsigned int op = cache_work->op; + phys_addr_t difference; if (!h || !h->alloc) return -EFAULT; @@ -204,11 +205,10 @@ per_page_phy_cache_maint: h->flags != NVMAP_HANDLE_INNER_CACHEABLE); out: - if (!err) { - nvmap_stats_inc(NS_CFLUSH_DONE, pend - pstart); - } + if (!err && !check_sub_overflow(pend, pstart, &difference)) + nvmap_stats_inc(NS_CFLUSH_DONE, difference); - trace_nvmap_cache_flush(pend - pstart, + trace_nvmap_cache_flush(difference, nvmap_stats_read(NS_ALLOC), nvmap_stats_read(NS_CFLUSH_RQ), nvmap_stats_read(NS_CFLUSH_DONE));