Skip to contentSkip to conversation

perf: Add Arm CMN-600 PMU driver

bug report Dan Carpenter 1 participant 1 message Sep 30, 2020

lore
Share & tools
lore
#0 lore raw

Hello Robin Murphy,

The patch 0ba64770a2f2: "perf: Add Arm CMN-600 PMU driver" from Sep 18, 2020, leads to the following static checker warning:

	drivers/perf/arm-cmn.c:1156 arm_cmn_pmu_offline_cpu()
	error: potential NULL dereference 'cmn'.

drivers/perf/arm-cmn.c
1150 static int arm_cmn_pmu_offline_cpu(unsigned int cpu, struct hlist_node *node) 1151 {
1152 struct arm_cmn *cmn;
1153 unsigned int target;
1154
1155 cmn = hlist_entry_safe(node, struct arm_cmn, cpuhp_node);
1156 if (cpu != cmn->cpu)

                           ^^^^^^^^

It doesn't make sense to use hlist_entry_safe() and then dereference "cmn" without checking for NULL. It should either be hlist_entry() or there should be a NULL check.

  1157                  return 0;
  1158  
  1159          target = cpumask_any_but(cpu_online_mask, cpu);
  1160          if (target >= nr_cpu_ids)
  1161                  return 0;
  1162  
  1163          perf_pmu_migrate_context(&cmn->pmu, cpu, target);
  1164          cmn->cpu = target;
  1165          return 0;
  1166  }

regards,
dan carpenter

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel