From: Saeed Mahameed <saeedm@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
Eran Ben Elisha <eranbe@mellanox.com>,
Dan Carpenter <dan.carpenter@oracle.com>,
Saeed Mahameed <saeedm@mellanox.com>
Subject: [net-next 01/14] net/mlx5e: Fix static checker warning of potential pointer math issue
Date: Thu, 5 Sep 2019 21:50:54 +0000 [thread overview]
Message-ID: <20190905215034.22713-2-saeedm@mellanox.com> (raw)
In-Reply-To: <20190905215034.22713-1-saeedm@mellanox.com>
From: Eran Ben Elisha <eranbe@mellanox.com>
Cited patch have an issue in WARN_ON_ONCE check, with wrong address ranges
are compared. Fix that by changing pointer types from u64* to void*. This
will also make code simpler to read.
In addition mlx5e_hv_vhca_fill_ring_stats can get void pointer, so remove
the unnecessary casting when calling it.
Found by static checker:
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)
Fixes: cef35af34d6d ("net/mlx5e: Add mlx5e HV VHCA stats agent")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
.../net/ethernet/mellanox/mlx5/core/en/hv_vhca_stats.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/hv_vhca_stats.c b/drivers/net/ethernet/mellanox/mlx5/core/en/hv_vhca_stats.c
index c37b4acd9bd5..b3a249b2a482 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/hv_vhca_stats.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/hv_vhca_stats.c
@@ -30,22 +30,21 @@ mlx5e_hv_vhca_fill_ring_stats(struct mlx5e_priv *priv, int ch,
}
}
-static void mlx5e_hv_vhca_fill_stats(struct mlx5e_priv *priv, u64 *data,
+static void mlx5e_hv_vhca_fill_stats(struct mlx5e_priv *priv, void *data,
int buf_len)
{
int ch, i = 0;
for (ch = 0; ch < priv->max_nch; ch++) {
- u64 *buf = data + i;
+ void *buf = data + i;
if (WARN_ON_ONCE(buf +
sizeof(struct mlx5e_hv_vhca_per_ring_stats) >
data + buf_len))
return;
- mlx5e_hv_vhca_fill_ring_stats(priv, ch,
- (struct mlx5e_hv_vhca_per_ring_stats *)buf);
- i += sizeof(struct mlx5e_hv_vhca_per_ring_stats) / sizeof(u64);
+ mlx5e_hv_vhca_fill_ring_stats(priv, ch, buf);
+ i += sizeof(struct mlx5e_hv_vhca_per_ring_stats);
}
}
--
2.21.0
next prev parent reply other threads:[~2019-09-05 21:51 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-05 21:50 [pull request][net-next 00/14] Mellanox, mlx5 cleanups & port congestion stats Saeed Mahameed
2019-09-05 21:50 ` Saeed Mahameed [this message]
2019-09-05 21:50 ` [net-next 02/14] net/mlx5: Kconfig: Fix MLX5_CORE dependency with PCI_HYPERV_INTERFACE Saeed Mahameed
2019-09-05 21:50 ` [net-next 03/14] net/mlx5e: Use ipv6_stub to avoid dependency with ipv6 being a module Saeed Mahameed
2019-09-05 21:51 ` [net-next 04/14] net/mlx5e: Remove leftover declaration Saeed Mahameed
2019-09-05 21:51 ` [net-next 05/14] net/mlx5: fix spelling mistake "offlaods" -> "offloads" Saeed Mahameed
2019-09-05 21:51 ` [net-next 06/14] net/mlx5: fix missing assignment of variable err Saeed Mahameed
2019-09-05 21:51 ` [net-next 07/14] net/mlx5: Use PTR_ERR_OR_ZERO rather than its implementation Saeed Mahameed
2019-09-05 21:51 ` [net-next 08/14] net/mlx5e: kTLS, Remove unused function parameter Saeed Mahameed
2019-09-05 21:51 ` [net-next 09/14] net/mlx5e: Remove unnecessary clear_bit()s Saeed Mahameed
2019-09-05 21:51 ` [net-next 10/14] net/mlx5: DR, Remove useless set memory to zero use memset() Saeed Mahameed
2019-09-05 21:51 ` [net-next 11/14] net/mlx5: DR, Fix error return code in dr_domain_init_resources() Saeed Mahameed
2019-09-05 21:51 ` [net-next 12/14] net/mlx5: DR, Remove redundant dev_name print from err log Saeed Mahameed
2019-09-05 21:51 ` [net-next 13/14] net/mlx5: Expose HW capability bits for port buffer per priority congestion counters Saeed Mahameed
2019-09-05 21:51 ` [net-next 14/14] net/mlx5e: Add port buffer's " Saeed Mahameed
2019-09-07 15:40 ` [pull request][net-next 00/14] Mellanox, mlx5 cleanups & port congestion stats David Miller
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=20190905215034.22713-2-saeedm@mellanox.com \
--to=saeedm@mellanox.com \
--cc=dan.carpenter@oracle.com \
--cc=davem@davemloft.net \
--cc=eranbe@mellanox.com \
--cc=netdev@vger.kernel.org \
/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