public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [bug report] driver/perf: Add PMU driver for the ARM DMC-620 memory controller
@ 2020-12-07 17:56 Dan Carpenter
  2020-12-09 20:57 ` Tuan Phan
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2020-12-07 17:56 UTC (permalink / raw)
  To: tuanphan; +Cc: linux-arm-kernel

Hello Tuan Phan,

The patch 53c218da220c: "driver/perf: Add PMU driver for the ARM
DMC-620 memory controller" from Nov 4, 2020, leads to the following
static checker warning:

	drivers/perf/arm_dmc620_pmu.c:612 dmc620_pmu_cpu_teardown()
	error: potential NULL dereference 'irq'.

drivers/perf/arm_dmc620_pmu.c
   604  static int dmc620_pmu_cpu_teardown(unsigned int cpu,
   605                                     struct hlist_node *node)
   606  {
   607          struct dmc620_pmu_irq *irq;
   608          struct dmc620_pmu *dmc620_pmu;
   609          unsigned int target;
   610  
   611          irq = hlist_entry_safe(node, struct dmc620_pmu_irq, node);
   612          if (cpu != irq->cpu)

There isn't any point to using hlist_entry_safe() instead of hlist_entry()
when we're not going to check for NULL returns.

   613                  return 0;
   614  
   615          target = cpumask_any_but(cpu_online_mask, cpu);
   616          if (target >= nr_cpu_ids)
   617                  return 0;
   618  
   619          /* We're only reading, but this isn't the place to be involving RCU */
   620          mutex_lock(&dmc620_pmu_irqs_lock);
   621          list_for_each_entry(dmc620_pmu, &irq->pmus_node, pmus_node)
   622                  perf_pmu_migrate_context(&dmc620_pmu->pmu, irq->cpu, target);
   623          mutex_unlock(&dmc620_pmu_irqs_lock);

regards,
dan carpenter

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [bug report] driver/perf: Add PMU driver for the ARM DMC-620 memory controller
  2020-12-07 17:56 [bug report] driver/perf: Add PMU driver for the ARM DMC-620 memory controller Dan Carpenter
@ 2020-12-09 20:57 ` Tuan Phan
  0 siblings, 0 replies; 2+ messages in thread
From: Tuan Phan @ 2020-12-09 20:57 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Tuan Phan, linux-arm-kernel

Thanks Dan, I will look at it and provide a patch.

> On Dec 7, 2020, at 9:56 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> 
> Hello Tuan Phan,
> 
> The patch 53c218da220c: "driver/perf: Add PMU driver for the ARM
> DMC-620 memory controller" from Nov 4, 2020, leads to the following
> static checker warning:
> 
> 	drivers/perf/arm_dmc620_pmu.c:612 dmc620_pmu_cpu_teardown()
> 	error: potential NULL dereference 'irq'.
> 
> drivers/perf/arm_dmc620_pmu.c
>   604  static int dmc620_pmu_cpu_teardown(unsigned int cpu,
>   605                                     struct hlist_node *node)
>   606  {
>   607          struct dmc620_pmu_irq *irq;
>   608          struct dmc620_pmu *dmc620_pmu;
>   609          unsigned int target;
>   610  
>   611          irq = hlist_entry_safe(node, struct dmc620_pmu_irq, node);
>   612          if (cpu != irq->cpu)
> 
> There isn't any point to using hlist_entry_safe() instead of hlist_entry()
> when we're not going to check for NULL returns.
> 
>   613                  return 0;
>   614  
>   615          target = cpumask_any_but(cpu_online_mask, cpu);
>   616          if (target >= nr_cpu_ids)
>   617                  return 0;
>   618  
>   619          /* We're only reading, but this isn't the place to be involving RCU */
>   620          mutex_lock(&dmc620_pmu_irqs_lock);
>   621          list_for_each_entry(dmc620_pmu, &irq->pmus_node, pmus_node)
>   622                  perf_pmu_migrate_context(&dmc620_pmu->pmu, irq->cpu, target);
>   623          mutex_unlock(&dmc620_pmu_irqs_lock);
> 
> regards,
> dan carpenter


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-09 20:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-07 17:56 [bug report] driver/perf: Add PMU driver for the ARM DMC-620 memory controller Dan Carpenter
2020-12-09 20:57 ` Tuan Phan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox