misc: tegra-profiler: fix coverity defect
Igor Nabirushkin [Sat, 4 Jun 2016 04:27:33 +0000 (08:27 +0400)]
Fix coverity defect "Out-of-bounds access".

Coverity ID 29588

Bug 200192567

Change-Id: I8d1057d29216eeabdd24686fa12a52d7e2a220d4
Signed-off-by: Igor Nabirushkin <inabirushkin@nvidia.com>
Reviewed-on: http://git-master/r/1171550
(cherry picked from commit 7c76afae5c3fcac4c7365d3fd1fb5706e2b64446)
Reviewed-on: http://git-master/r/1249579
(cherry picked from commit 2ffb50ff95239cf489672c30f1ba40014e780da5)

drivers/misc/tegra-profiler/armv8_pmu.c

index 3a515da..818c7dc 100644 (file)
@@ -342,15 +342,17 @@ get_free_counters(unsigned long *bitmap, int nbits, int *ccntr)
 {
        int cc;
        u32 cntens;
+       unsigned long cntens_bitmap;
 
        struct quadd_pmu_ctx *local_pmu_ctx = &__get_cpu_var(pmu_ctx);
 
        cntens = armv8_pmu_pmcntenset_read();
        cntens = ~cntens & (local_pmu_ctx->counters_mask | QUADD_ARMV8_CCNT);
 
+       cntens_bitmap = cntens;
+
        bitmap_zero(bitmap, nbits);
-       bitmap_copy(bitmap, (unsigned long *)&cntens,
-                   BITS_PER_BYTE * sizeof(u32));
+       bitmap_copy(bitmap, &cntens_bitmap, BITS_PER_BYTE * sizeof(u32));
 
        cc = (cntens & QUADD_ARMV8_CCNT) ? 1 : 0;