Skip to content

Commit 8ddf4ef

Browse files
andy-shevwilldeacon
authored andcommitted
perf/smmuv3: Don't cast parameter in bit operations
While in this particular case it would not be a (critical) issue, the pattern itself is bad and error prone in case somebody blindly copies to their code. Don't cast parameter to unsigned long pointer in the bit operations. Instead copy to a local variable on stack of a proper type and use. Note, new compilers might warn on this line for potential outbound access. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Robin Murphy <robin.murphy@arm.com> Link: https://lore.kernel.org/r/20220209184758.56578-1-andriy.shevchenko@linux.intel.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent 30de2b5 commit 8ddf4ef

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/perf/arm_smmuv3_pmu.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,7 @@ static int smmu_pmu_offline_cpu(unsigned int cpu, struct hlist_node *node)
654654
static irqreturn_t smmu_pmu_handle_irq(int irq_num, void *data)
655655
{
656656
struct smmu_pmu *smmu_pmu = data;
657+
DECLARE_BITMAP(ovs, BITS_PER_TYPE(u64));
657658
u64 ovsr;
658659
unsigned int idx;
659660

@@ -663,7 +664,8 @@ static irqreturn_t smmu_pmu_handle_irq(int irq_num, void *data)
663664

664665
writeq(ovsr, smmu_pmu->reloc_base + SMMU_PMCG_OVSCLR0);
665666

666-
for_each_set_bit(idx, (unsigned long *)&ovsr, smmu_pmu->num_counters) {
667+
bitmap_from_u64(ovs, ovsr);
668+
for_each_set_bit(idx, ovs, smmu_pmu->num_counters) {
667669
struct perf_event *event = smmu_pmu->events[idx];
668670
struct hw_perf_event *hwc;
669671

0 commit comments

Comments
 (0)