* [bug report] fpga: dfl: fme: add performance reporting support
@ 2020-05-02 13:24 Dan Carpenter
2020-05-06 6:31 ` Xu Yilun
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2020-05-02 13:24 UTC (permalink / raw)
To: hao.wu; +Cc: linux-fpga
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [bug report] fpga: dfl: fme: add performance reporting support
2020-05-02 13:24 [bug report] fpga: dfl: fme: add performance reporting support Dan Carpenter
@ 2020-05-06 6:31 ` Xu Yilun
2020-05-07 6:42 ` Wu, Hao
0 siblings, 1 reply; 3+ messages in thread
From: Xu Yilun @ 2020-05-06 6:31 UTC (permalink / raw)
To: Dan Carpenter; +Cc: hao.wu, linux-fpga
On Sat, May 02, 2020 at 04:24:19PM +0300, Dan Carpenter wrote:
> 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.
Thanks for catching this. Will fix it.
Regards,
Yilun.
>
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [bug report] fpga: dfl: fme: add performance reporting support
2020-05-06 6:31 ` Xu Yilun
@ 2020-05-07 6:42 ` Wu, Hao
0 siblings, 0 replies; 3+ messages in thread
From: Wu, Hao @ 2020-05-07 6:42 UTC (permalink / raw)
To: Xu, Yilun, Dan Carpenter; +Cc: linux-fpga@vger.kernel.org
> On Sat, May 02, 2020 at 04:24:19PM +0300, Dan Carpenter wrote:
> > 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.
>
> 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
>
> Regards,
> Yilun.
>
> >
> > 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-05-07 6:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-02 13:24 [bug report] fpga: dfl: fme: add performance reporting support Dan Carpenter
2020-05-06 6:31 ` Xu Yilun
2020-05-07 6:42 ` Wu, Hao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).