fpga: dfl: fme: add performance reporting support
Hello Wu Hao,
The patch 724142f8c42a: "fpga: dfl: fme: add performance reporting support" from Apr 27, 2020, leads to the following static checker warning:
drivers/fpga/dfl-fme-perf.c:948 fme_perf_offline_cpu() error: potential NULL dereference 'priv'.
drivers/fpga/dfl-fme-perf.c
941 static int fme_perf_offline_cpu(unsigned int cpu, struct hlist_node *node) 942 {
943 struct fme_perf_priv *priv;
944 int target;
945
946 priv = hlist_entry_safe(node, struct fme_perf_priv, node);
^^^^^It doesn't make sense to use the _safe() version if we're not going to check for NULL.
947 948 if (cpu != priv->cpu) 949 return 0; 950 951 target = cpumask_any_but(cpu_online_mask, cpu); 952 if (target >= nr_cpu_ids) 953 return 0; 954 955 priv->cpu = target; 956 return 0; 957 }
regards,
dan carpenter
Xu Yilun
maintainerQuoted 11 lines · Dan Carpenter
Hello Wu Hao,
The patch
724142f8c42a: "fpga: dfl: fme: add performance reporting support" from Apr 27, 2020, leads to the following static checker warning:drivers/fpga/dfl-fme-perf.c:948 fme_perf_offline_cpu() error: potential NULL dereference 'priv'.
drivers/fpga/dfl-fme-perf.c
941 static intfme_perf_offline_cpu(unsigned int cpu, struct hlist_node *node)
Quoted 8 lines
942 { 943 struct fme_perf_priv *priv; 944 int target; 945 946 priv = hlist_entry_safe(node, struct fme_perf_priv, node); ^^^^^It doesn't make sense to use the
_safe()version if we're not going to check for NULL.
Thanks for catching this. Will fix it.
Regards,
Yilun.
Quoted 15 lines
947 948 if (cpu != priv->cpu) 949 return 0; 950 951 target = cpumask_any_but(cpu_online_mask, cpu); 952 if (target >= nr_cpu_ids) 953 return 0; 954 955 priv->cpu = target; 956 return 0; 957 }regards,
dan carpenter
Quoted 22 lines · Dan Carpenter
Quoted 11 lines
Hello Wu Hao,
The patch
724142f8c42a: "fpga: dfl: fme: add performance reporting support" from Apr 27, 2020, leads to the following static checker warning:drivers/fpga/dfl-fme-perf.c:948 fme_perf_offline_cpu() error: potential NULL dereference 'priv'.
drivers/fpga/dfl-fme-perf.c
941 static int fme_perf_offline_cpu(unsigned int cpu, structhlist_node*node)
Quoted 8 lines
942 { 943 struct fme_perf_priv *priv; 944 int target; 945 946 priv = hlist_entry_safe(node, struct fme_perf_priv, node); ^^^^^It doesn't make sense to use the
_safe()version if we're not going to check for NULL.
Quoted 1 line
Thanks for catching this. Will fix it.
Yes, it's not necessary to use _safe version here.
Thanks Dan for reporting this, and thanks Yilun for covering this when I was on leave.
Hao
Quoted 19 lines
Regards,
Yilun.Quoted 15 lines
947 948 if (cpu != priv->cpu) 949 return 0; 950 951 target = cpumask_any_but(cpu_online_mask, cpu); 952 if (target >= nr_cpu_ids) 953 return 0; 954 955 priv->cpu = target; 956 return 0; 957 }regards,
dan carpenter