public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Eran Ben Elisha <eranbe@mellanox.com>
Cc: "linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
	Saeed Mahameed <saeedm@mellanox.com>
Subject: Re: [bug report] net/mlx5e: Add mlx5e HV VHCA stats agent
Date: Wed, 28 Aug 2019 11:46:17 +0300	[thread overview]
Message-ID: <20190828084616.GA8372@kadam> (raw)
In-Reply-To: <c48f8323-553f-b726-3b4e-79ab8167e1c3@mellanox.com>

On Wed, Aug 28, 2019 at 07:41:14AM +0000, Eran Ben Elisha wrote:
> 
> 
> On 8/26/2019 3:56 PM, Dan Carpenter wrote:
> > Hello Eran Ben Elisha,
> > 
> > The patch cef35af34d6d: "net/mlx5e: Add mlx5e HV VHCA stats agent"
> > from Aug 22, 2019, leads to the following static checker warning:
> > 
> > 	drivers/net/ethernet/mellanox/mlx5/core/en/hv_vhca_stats.c:41 mlx5e_hv_vhca_fill_stats()
> > 	warn: potential pointer math issue ('buf' is a u64 pointer)
> > 
> > drivers/net/ethernet/mellanox/mlx5/core/en/hv_vhca_stats.c
> >      33  static void mlx5e_hv_vhca_fill_stats(struct mlx5e_priv *priv, u64 *data,
> >                                                                        ^^^^^^^^^
> > data is a u64 pointer.
> > 
> >      34                                       int buf_len)
> >      35  {
> >      36          int ch, i = 0;
> >      37
> >      38          for (ch = 0; ch < priv->max_nch; ch++) {
> >      39                  u64 *buf = data + i;
> >                          ^^^^^^^^
> > 
> >      40
> >      41                  if (WARN_ON_ONCE(buf +
> >      42                                   sizeof(struct mlx5e_hv_vhca_per_ring_stats) >
> >                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > This pointer math doesn't work.  I'm surprised the warning doesn't
> > trigger.
> 
> It it not triggered as both 'data' and 'buf' are u64*,
> and sizeof(struct mlx5e_hv_vhca_per_ring_stats) < buf_len as expected.
> This checker does the work, but over wrong range.

Ah.  Of course.  Thanks!

regards,
dan carpenter


      reply	other threads:[~2019-08-28  8:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-26 12:56 [bug report] net/mlx5e: Add mlx5e HV VHCA stats agent Dan Carpenter
2019-08-28  7:41 ` Eran Ben Elisha
2019-08-28  8:46   ` Dan Carpenter [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190828084616.GA8372@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=eranbe@mellanox.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=saeedm@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox