gpu: Fix a memory tracking bug with kmallocs.

If a kmalloc was made by one PID and freed by another, it would not be
tracked correctly and appeared to leak. The memory did not actually leak.

Bug: 38184708

Change-Id: Ia293c210de6b01f2e909a0f3f05d21319151d9a5
Signed-off-by: Alistair Strachan <alistair.strachan@imgtec.com>
diff --git a/drivers/staging/imgtec/rogue/allocmem.c b/drivers/staging/imgtec/rogue/allocmem.c
index 0699da8..ffabcf5 100644
--- a/drivers/staging/imgtec/rogue/allocmem.c
+++ b/drivers/staging/imgtec/rogue/allocmem.c
@@ -365,7 +365,10 @@
 		{
 #if !defined(PVR_DISABLE_KMALLOC_MEMSTATS)
 #if !defined(PVRSRV_ENABLE_MEMORY_STATS)
-			PVRSRVStatsDecrMemAllocStat(PVRSRV_MEM_ALLOC_TYPE_KMALLOC, ksize(pvMem));
+			{
+				IMG_UINT32 *puiTemp = (IMG_UINT32*) (((IMG_BYTE*)pvMem) + (ksize(pvMem) - ALLOCMEM_MEMSTATS_PADDING));
+				PVRSRVStatsDecrMemKAllocStat(ksize(pvMem), *puiTemp);
+			}
 #else
 			PVRSRVStatsRemoveMemAllocRecord(PVRSRV_MEM_ALLOC_TYPE_KMALLOC,
 			                                (IMG_UINT64)(uintptr_t) pvMem);