Netdev Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH net-next v2] net/mlx5e: Fix uninitialised struct field moder.comps
@ 2021-04-20  7:00 wangyunjian
  2021-04-20  7:09 ` Zhu Yanjun
  2021-05-04  7:27 ` Leon Romanovsky
  0 siblings, 2 replies; 6+ messages in thread
From: wangyunjian @ 2021-04-20  7:00 UTC (permalink / raw)
  To: kuba, davem; +Cc: saeedm, netdev, dingxiaoxiong, Yunjian Wang

From: Yunjian Wang <wangyunjian@huawei.com>

The 'comps' struct field in 'moder' is not being initialized in
mlx5e_get_def_rx_moderation() and mlx5e_get_def_tx_moderation().
So initialize 'moder' to zero to avoid the issue.

Addresses-Coverity: ("Uninitialized scalar variable")
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
v2: update mlx5e_get_def_tx_moderation() also needs fixing
---
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 5db63b9f3b70..17a817b7e539 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -4868,7 +4868,7 @@ static bool slow_pci_heuristic(struct mlx5_core_dev *mdev)
 
 static struct dim_cq_moder mlx5e_get_def_tx_moderation(u8 cq_period_mode)
 {
-	struct dim_cq_moder moder;
+	struct dim_cq_moder moder = {};
 
 	moder.cq_period_mode = cq_period_mode;
 	moder.pkts = MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_PKTS;
@@ -4881,7 +4881,7 @@ static struct dim_cq_moder mlx5e_get_def_tx_moderation(u8 cq_period_mode)
 
 static struct dim_cq_moder mlx5e_get_def_rx_moderation(u8 cq_period_mode)
 {
-	struct dim_cq_moder moder;
+	struct dim_cq_moder moder = {};
 
 	moder.cq_period_mode = cq_period_mode;
 	moder.pkts = MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_PKTS;
-- 
2.23.0


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

* Re: [PATCH net-next v2] net/mlx5e: Fix uninitialised struct field moder.comps
  2021-04-20  7:00 [PATCH net-next v2] net/mlx5e: Fix uninitialised struct field moder.comps wangyunjian
@ 2021-04-20  7:09 ` Zhu Yanjun
  2021-04-20  9:21   ` Leon Romanovsky
  2021-05-04  7:27 ` Leon Romanovsky
  1 sibling, 1 reply; 6+ messages in thread
From: Zhu Yanjun @ 2021-04-20  7:09 UTC (permalink / raw)
  To: wangyunjian
  Cc: Jakub Kicinski, David S. Miller, saeedm, netdev, dingxiaoxiong

On Tue, Apr 20, 2021 at 3:01 PM wangyunjian <wangyunjian@huawei.com> wrote:
>
> From: Yunjian Wang <wangyunjian@huawei.com>
>
> The 'comps' struct field in 'moder' is not being initialized in
> mlx5e_get_def_rx_moderation() and mlx5e_get_def_tx_moderation().
> So initialize 'moder' to zero to avoid the issue.
>
> Addresses-Coverity: ("Uninitialized scalar variable")
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> ---
> v2: update mlx5e_get_def_tx_moderation() also needs fixing
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> index 5db63b9f3b70..17a817b7e539 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> @@ -4868,7 +4868,7 @@ static bool slow_pci_heuristic(struct mlx5_core_dev *mdev)
>
>  static struct dim_cq_moder mlx5e_get_def_tx_moderation(u8 cq_period_mode)
>  {
> -       struct dim_cq_moder moder;

> +       struct dim_cq_moder moder = {};

If I remember correctly, some gcc compiler will report errors about this "{}".

Zhu Yanjun

>
>         moder.cq_period_mode = cq_period_mode;
>         moder.pkts = MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_PKTS;
> @@ -4881,7 +4881,7 @@ static struct dim_cq_moder mlx5e_get_def_tx_moderation(u8 cq_period_mode)
>
>  static struct dim_cq_moder mlx5e_get_def_rx_moderation(u8 cq_period_mode)
>  {
> -       struct dim_cq_moder moder;
> +       struct dim_cq_moder moder = {};
>
>         moder.cq_period_mode = cq_period_mode;
>         moder.pkts = MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_PKTS;
> --
> 2.23.0
>

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

* Re: [PATCH net-next v2] net/mlx5e: Fix uninitialised struct field moder.comps
  2021-04-20  7:09 ` Zhu Yanjun
@ 2021-04-20  9:21   ` Leon Romanovsky
  2021-04-20  9:28     ` Zhu Yanjun
  0 siblings, 1 reply; 6+ messages in thread
From: Leon Romanovsky @ 2021-04-20  9:21 UTC (permalink / raw)
  To: Zhu Yanjun, wangyunjian
  Cc: Jakub Kicinski, David S. Miller, saeedm, netdev, dingxiaoxiong

On Tue, Apr 20, 2021 at 03:09:03PM +0800, Zhu Yanjun wrote:
> On Tue, Apr 20, 2021 at 3:01 PM wangyunjian <wangyunjian@huawei.com> wrote:
> >
> > From: Yunjian Wang <wangyunjian@huawei.com>
> >
> > The 'comps' struct field in 'moder' is not being initialized in
> > mlx5e_get_def_rx_moderation() and mlx5e_get_def_tx_moderation().
> > So initialize 'moder' to zero to avoid the issue.

Please state that it is false alarm and this patch doesn't fix anything
except broken static analyzer tool.

> >
> > Addresses-Coverity: ("Uninitialized scalar variable")
> > Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> > ---
> > v2: update mlx5e_get_def_tx_moderation() also needs fixing
> > ---
> >  drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> > index 5db63b9f3b70..17a817b7e539 100644
> > --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> > @@ -4868,7 +4868,7 @@ static bool slow_pci_heuristic(struct mlx5_core_dev *mdev)
> >
> >  static struct dim_cq_moder mlx5e_get_def_tx_moderation(u8 cq_period_mode)
> >  {
> > -       struct dim_cq_moder moder;
> 
> > +       struct dim_cq_moder moder = {};
> 
> If I remember correctly, some gcc compiler will report errors about this "{}".

Kernel doesn't support such compilers.

Thanks

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

* Re: [PATCH net-next v2] net/mlx5e: Fix uninitialised struct field moder.comps
  2021-04-20  9:21   ` Leon Romanovsky
@ 2021-04-20  9:28     ` Zhu Yanjun
  2021-04-20 11:05       ` Leon Romanovsky
  0 siblings, 1 reply; 6+ messages in thread
From: Zhu Yanjun @ 2021-04-20  9:28 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: wangyunjian, Jakub Kicinski, David S. Miller, saeedm, netdev,
	dingxiaoxiong

On Tue, Apr 20, 2021 at 5:21 PM Leon Romanovsky <leon@kernel.org> wrote:
>
> On Tue, Apr 20, 2021 at 03:09:03PM +0800, Zhu Yanjun wrote:
> > On Tue, Apr 20, 2021 at 3:01 PM wangyunjian <wangyunjian@huawei.com> wrote:
> > >
> > > From: Yunjian Wang <wangyunjian@huawei.com>
> > >
> > > The 'comps' struct field in 'moder' is not being initialized in
> > > mlx5e_get_def_rx_moderation() and mlx5e_get_def_tx_moderation().
> > > So initialize 'moder' to zero to avoid the issue.
>
> Please state that it is false alarm and this patch doesn't fix anything
> except broken static analyzer tool.
>
> > >
> > > Addresses-Coverity: ("Uninitialized scalar variable")
> > > Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> > > ---
> > > v2: update mlx5e_get_def_tx_moderation() also needs fixing
> > > ---
> > >  drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> > > index 5db63b9f3b70..17a817b7e539 100644
> > > --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> > > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> > > @@ -4868,7 +4868,7 @@ static bool slow_pci_heuristic(struct mlx5_core_dev *mdev)
> > >
> > >  static struct dim_cq_moder mlx5e_get_def_tx_moderation(u8 cq_period_mode)
> > >  {
> > > -       struct dim_cq_moder moder;
> >
> > > +       struct dim_cq_moder moder = {};
> >
> > If I remember correctly, some gcc compiler will report errors about this "{}".
>
> Kernel doesn't support such compilers.

Are you sure? Why are you so confirmative?

Zhu Yanjun

>
> Thanks

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

* Re: [PATCH net-next v2] net/mlx5e: Fix uninitialised struct field moder.comps
  2021-04-20  9:28     ` Zhu Yanjun
@ 2021-04-20 11:05       ` Leon Romanovsky
  0 siblings, 0 replies; 6+ messages in thread
From: Leon Romanovsky @ 2021-04-20 11:05 UTC (permalink / raw)
  To: Zhu Yanjun
  Cc: wangyunjian, Jakub Kicinski, David S. Miller, saeedm, netdev,
	dingxiaoxiong

On Tue, Apr 20, 2021 at 05:28:43PM +0800, Zhu Yanjun wrote:
> On Tue, Apr 20, 2021 at 5:21 PM Leon Romanovsky <leon@kernel.org> wrote:
> >
> > On Tue, Apr 20, 2021 at 03:09:03PM +0800, Zhu Yanjun wrote:
> > > On Tue, Apr 20, 2021 at 3:01 PM wangyunjian <wangyunjian@huawei.com> wrote:
> > > >
> > > > From: Yunjian Wang <wangyunjian@huawei.com>
> > > >
> > > > The 'comps' struct field in 'moder' is not being initialized in
> > > > mlx5e_get_def_rx_moderation() and mlx5e_get_def_tx_moderation().
> > > > So initialize 'moder' to zero to avoid the issue.
> >
> > Please state that it is false alarm and this patch doesn't fix anything
> > except broken static analyzer tool.
> >
> > > >
> > > > Addresses-Coverity: ("Uninitialized scalar variable")
> > > > Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> > > > ---
> > > > v2: update mlx5e_get_def_tx_moderation() also needs fixing
> > > > ---
> > > >  drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 4 ++--
> > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> > > > index 5db63b9f3b70..17a817b7e539 100644
> > > > --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> > > > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> > > > @@ -4868,7 +4868,7 @@ static bool slow_pci_heuristic(struct mlx5_core_dev *mdev)
> > > >
> > > >  static struct dim_cq_moder mlx5e_get_def_tx_moderation(u8 cq_period_mode)
> > > >  {
> > > > -       struct dim_cq_moder moder;
> > >
> > > > +       struct dim_cq_moder moder = {};
> > >
> > > If I remember correctly, some gcc compiler will report errors about this "{}".
> >
> > Kernel doesn't support such compilers.
> 
> Are you sure? Why are you so confirmative?

Yes, I'm sure.

Please read this whole discussion, I hope that it will answer your
question on why I'm so sure.
https://lore.kernel.org/linux-rdma/20200730192026.110246-1-yepeilin.cs@gmail.com/

> 
> Zhu Yanjun
> 
> >
> > Thanks

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

* Re: [PATCH net-next v2] net/mlx5e: Fix uninitialised struct field moder.comps
  2021-04-20  7:00 [PATCH net-next v2] net/mlx5e: Fix uninitialised struct field moder.comps wangyunjian
  2021-04-20  7:09 ` Zhu Yanjun
@ 2021-05-04  7:27 ` Leon Romanovsky
  1 sibling, 0 replies; 6+ messages in thread
From: Leon Romanovsky @ 2021-05-04  7:27 UTC (permalink / raw)
  To: wangyunjian; +Cc: kuba, davem, saeedm, netdev, dingxiaoxiong

On Tue, Apr 20, 2021 at 03:00:26PM +0800, wangyunjian wrote:
> From: Yunjian Wang <wangyunjian@huawei.com>
> 
> The 'comps' struct field in 'moder' is not being initialized in
> mlx5e_get_def_rx_moderation() and mlx5e_get_def_tx_moderation().
> So initialize 'moder' to zero to avoid the issue.
> 
> Addresses-Coverity: ("Uninitialized scalar variable")
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> ---
> v2: update mlx5e_get_def_tx_moderation() also needs fixing

Actually grep other all "struct dim_cq_moder ...;" declarations shows
many places like this. Are you going to change them too?

Thanks

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

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-20  7:00 [PATCH net-next v2] net/mlx5e: Fix uninitialised struct field moder.comps wangyunjian
2021-04-20  7:09 ` Zhu Yanjun
2021-04-20  9:21   ` Leon Romanovsky
2021-04-20  9:28     ` Zhu Yanjun
2021-04-20 11:05       ` Leon Romanovsky
2021-05-04  7:27 ` Leon Romanovsky

Netdev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/netdev/0 netdev/git/0.git
	git clone --mirror https://lore.kernel.org/netdev/1 netdev/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 netdev netdev/ https://lore.kernel.org/netdev \
		netdev@vger.kernel.org
	public-inbox-index netdev

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.netdev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git